advancedandroid_teatime's People
Forkers
ehabhamdy srihi dahu3291 radsen rafaelanastacioalves adnanul hazemhabib bappyasif vimalvimi omicic megavak abdrrahmenz massaohigaskino ehbraheem esidem maximbravo toluwanio domoniquea kokoafantchao huy-coursework tuonbondol ahmedmolawale evgansoft chenzhuo914 delaroy eamedina87 nishantdesigns himakiran purbohadi polash sayor20 karabulut1989 geoholix davegogol alancowap aidenak pmalland huyttq-fsofter dariomartin-mm barbietunnie dariomartin ekosp dougouk gauthamrajesh cmoney667 morshed-islam plusema86 shawn-ma-mel gohilchirag stevendende jpventura yi904835116 ivzb techieeupload lixw1021 pieeet muirdh jenalgit bogdanorzea rb5988 atckersten teldot kornden ronnymakhuddin karthisammannan unorthodoxdev ed828a scaffeinate ggguille albarip ollerandres andre-gomes-oliveira mrdroid17 sivaprojects hrishikesh-kadam khinthirisoe saraf-10 carlosgilsaenz pritamtirpude redjack1888 yuleven dhanaruban selidinok makkhay sloshyd omracun vjauckus dreamskymxdan atofallis felislynx-silae ctp27 sapsztor kittytiger7 silkster87 tbreue2s nuhkoca jutikorn minasamircap vishalenrique attapalaceadvancedandroid_teatime's Issues
Gradle Dependancies in Android 3.1.3
If you want to use the latest versions of the libraries, here what you must do.
compile
is going to be replaced with implementation
soon. Compiler gives warnings regarding that so you should change it.
Testing-only dependancies should be changed from androidTestCompile
to androidTestImplementation
com.google.android.gms:play-services-appindexing:x.x.x
is obsolete as it is replaced with com.google.firebase:firebase-appindexing:x.x.x
where x.x.x
is the version you need.
Here is a changed version that uses the latest libraries. Anything with the $ in it is a String value that you can change if a new version comes out for those.
`dependencies {
def espresso_version = "3.0.2"
def android_support_version = "27.1.1"
def android_support_test_version = "1.0.2"
def firebase_version = "16.0.1"
implementation "com.android.support:design:$android_support_version"
implementation "com.android.support:support-annotations:$android_support_version"
implementation "com.google.firebase:firebase-appindexing:$firebase_version"
implementation "com.android.support.test.espresso:espresso-idling-resource:$espresso_version"
// Testing-only dependencies
androidTestImplementation "com.android.support:support-annotations:$android_support_version"
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espresso_version"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espresso_version"
androidTestImplementation "com.android.support.test:rules:$android_support_test_version"
androidTestImplementation "com.android.support.test:runner:$android_support_test_version"
}`
Change compileSdkVersion 25
to compileSdkVersion 27
The static imports would be highlighted in red on the InstrumentedTest java files. Just delete the static imports and add each one. Can alt + enter on items you have your cursor on that are needing imports.
TESP.02-Exercise-AddMenuActivityScreenTest TODO
The first TODO here is bad.
// TODO (1) Add annotation to specify AndroidJUnitRunner class as the default test runner
It should be
// COMPLETE (1) Add annotation to specify AndroidJUnit4 class as the default test runner
This is true for both the second and third exercises.
Steps to Upgrade Gradle Version and Plugin to Your Latest Android Studio
OutOfMemoryError because of loading large images OR too slow scrolling
Loading large images the resizing them by the system either throws OOM error or make the scrolling too slow.
To fix that move the images (tea images) to a new folder named drawable-nodpi
instead of locating them inside drawable
, in this case the images will be loaded with the same original size without resizing them to go along with device's density.
TESP.01-Exercise-FinishOrderActivityBasicTest - Bad logic in test
In the method clickDecrementButton_ChangesQuantityAndCost()
we should increment first the quantity to "1" to test that the decrement button works!. Comments updated accordingly:
@Test
public void clickDecrementButton_ChangesQuantityAndCost() {
// Check the initial quantity variable is zero
onView((withId(R.id.quantity_text_view))).check(matches(withText("0")));
// Click on increment button
onView((withId(R.id.increment_button)))
.perform(click());
// Click on decrement button
onView((withId(R.id.decrement_button)))
.perform(click());
// Verify that the decrement button decreases the quantity by 1
onView(withId(R.id.quantity_text_view)).check(matches(withText("0")));
// Verify that the decrement button also decreases the total cost from $5.00 to $0.00
onView(withId(R.id.cost_text_view)).check(matches(withText("$0.00")));
}
Exercise 4 TODO 6 and 8 registerIdlingResources() and unregisterIdlingResources() are deprecated
In TODO (6) Instead of:
Espresso.registerIdlingResources(mIdlingResource);
use:
IdlingRegistry.getInstance().register(mIdlingResource);
In TODO (8) instead of:
Espresso.unregisterIdlingResources(mIdlingResource);
use:
IdlingRegistry.getInstance().unregister(mIdlingResource);
TESP.02-Solution-AddMenuActivityScreenTest FAILS to pass tests
What's wrong? This is what I get when I run the solution code:
07/25 15:47:36: Launching MenuActivityScreenTest
$ adb push /Users/MHye/AndroidStudioProjects/AdvancedAndroid_TeaTime/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.example.android.teatime
$ adb shell pm install -r "/data/local/tmp/com.example.android.teatime"
Success
No apk changes detected since last installation, skipping installation of /Users/MHye/AndroidStudioProjects/AdvancedAndroid_TeaTime/app/build/outputs/apk/app-debug-androidTest.apk
$ adb shell am force-stop com.example.android.teatime.test
Running tests
$ adb shell am instrument -w -r -e debug false -e class com.example.android.teatime.MenuActivityScreenTest com.example.android.teatime.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running tests
android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1566)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at android.support.test.espresso.DataInteraction.load(DataInteraction.java:151)
at android.support.test.espresso.DataInteraction.perform(DataInteraction.java:128)
at com.example.android.teatime.MenuActivityScreenTest.clickGridViewItem_OpensOrderActivity(MenuActivityScreenTest.java:69)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
Tests ran to completion.
exercise-1, solution-1 issue
Hi guys, while trying to follow up with espresso lesson repos, I found the following
1- Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (25.1.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
"I guess my build tools issue but wasn't solved after changing the build number "
and I can't really get what's the reason for the following issues;
2- Error:Failed to crunch file D:\NanoDegree\TeaTime\AdvancedAndroid_TeaTime-TESP.01-Exercise-FinishOrderActivityBasicTest\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\9.8.0\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png into D:\NanoDegree\TeaTime\AdvancedAndroid_TeaTime-TESP.01-Exercise-FinishOrderActivityBasicTest\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png
3- Error:Execution failed for task ':app:mergeDebugResources'.
Error: Failed to crunch file D:\NanoDegree\TeaTime\AdvancedAndroid_TeaTime-TESP.01-Exercise-FinishOrderActivityBasicTest\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\9.8.0\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png into
D:\NanoDegree\TeaTime\AdvancedAndroid_TeaTime-TESP.01-Exercise-FinishOrderActivityBasicTest\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png
Besides android studio can't recognize testing classes
Hard Coded Initial Currency Format
At the initial state hard coded $ currency (R.string.initial_cost) is used
After the increase/decrease btn pressed NumberFormat.getCurrencyInstance().format() is used which it can changes the currency not just the quantity.
Cant build Exercise and Solution 4.
AndroidJUnit4 and ActivityTestRule are not recognized
I'm trying to do the first exercise. I added maven repository in the build.gradle
of the project, without this I can't compile the project:
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
Then I added the dependecies in the build.gradle
of the app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.teatime"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-annotations:25.1.0'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
// DONE (4) Add the required Espresso UI Testing dependencies
// Testing-only dependencies
androidTestCompile 'com.android.support:support-annotations:25.1.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}
But AndroidJUnit4 and ActivityTestRule are not recognized and I can't import them.
My Android Studio:
Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 20, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 8
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: com.microsoft.vso.idea, org.intellij.plugins.markdown
play-services-appindexing:9.8.0 is deprecated
In the Gradle build dependencies,
compile 'com.google.android.gms:play-services-appindexing:9.8.0' shows it is deprecated, please update the project to use the firebase 10.0.0 or above,
compile 'com.google.firebase:firebase-appindexing:11.2.2' solves it
TESP.02-Solution-AddMenuActivityScreenTest error
on running the test on an emulator, a error
android.support.test.espresso.PerformException: Error performing 'load adapter data' on view 'with id: com.example.android.teatime:id/tea_grid_view'.
occurs.
TESP.04-Solution-AddIdlingResourceMenuActivityTest
In TESP.04-Solution-AddIdlingResourceMenuActivityTest, MenuActivityScreenTest doesn't pass any more!!!
Also, in MenuActivity, there is a comment saying "We call ImageDownloader.downloadImage from onStart or onResume instead of in onCreate to ensure there is enougth time to register IdlingResource if the download is done too early (i.e. in onCreate)". This comment makes a feeling that mIdlingResource should be assigned and registered @before registerIdlingResource() before calling ImageDownloader.downloadImage() in onStart(). And in this case (similar to IdlingResourceSample), there would be no need to call getIdlingResource() in onCreate(). However, when using Logs, it is clear that all of onCreate(), onStart(), and onResume() in MenuActivity are actually called before @before registerIdlingResource() in IdlingResourceMenuActivityTest. That's why we must call getIdlingResource() in onCreate() to initialize mIdlingResource before using it in ImageDownloader.downloadImage().
Currency symbol system dependent
Initially the activity layout displays a currency symbol $ though once the button is pushed it displays the symbol of my region, the โฌ symbol.
It seems system dependent to me. The test case may need to be adapted to make it run successfully.
Cannot resolve symbol AndroidJUnit4
Upon adding libs to gradle I am getting cannot resolve AndroidJUnit4 error.
com.example.android.teatime E/art: Throwing OutOfMemoryError
Testing the first exercice on my Samsung S4, I have an out of memory error.
Is exist a way to increase the memory limit ?
The stack:
06-03 01:47:04.002 27206-27206/com.example.android.teatime E/art: Throwing OutOfMemoryError "Failed to allocate a 23040012 byte allocation with 1913468 free bytes and 1868KB until OOM" 06-03 01:47:04.002 27206-27206/com.example.android.teatime E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.teatime, PID: 27206 java.lang.OutOfMemoryError: Failed to allocate a 23040012 byte allocation with 1913468 free bytes and 1868KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:726) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:547) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014) at android.content.res.Resources.loadDrawableForCookie(Resources.java:3730) at android.content.res.Resources.loadDrawable(Resources.java:3603) at android.content.res.Resources.getDrawable(Resources.java:1852) at android.content.Context.getDrawable(Context.java:408) at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:30) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190) at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100) at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:73) at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:81) at com.example.android.teatime.TeaMenuAdapter.getView(TeaMenuAdapter.java:75) at android.widget.AbsListView.obtainView(AbsListView.java:2823) at android.widget.GridView.makeAndAddView(GridView.java:1437) at android.widget.GridView.makeRow(GridView.java:361) at android.widget.GridView.fillDown(GridView.java:302) at android.widget.GridView.fillFromTop(GridView.java:437) at android.widget.GridView.layoutChildren(GridView.java:1302) at android.widget.AbsListView.onLayout(AbsListView.java:2627) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556) at android.widget.LinearLayout.onLayout(LinearLayout.java:1465) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556) at android.widget.LinearLayout.onLayout(LinearLayout.java:1465) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2319) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2032) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) at android.view.Choreographer.doCallbacks(Choreographer.java:590) at android.view.Choreographer.doFrame(Choreographer.java:560)
android.support.test.espresso.IdlingResourceTimeoutException:
android.support.test.espresso.IdlingResourceTimeoutException: Wait for [SimpleIdlingResource] to become idle timed out
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
After following all the instructions, I am getting above exception while Running the test
IdlingResourceMenuActivityTest
at com.example.android.teatime.IdlingResourceMenuActivityTest.idlingResourceTest(IdlingResourceMenuActivityTest.java:40)
And Line 40 of the code wrote exactly as you've guided or written in your sample
onData(anything()).inAdapterView(withId(R.id.tea_grid_view)).atPosition(0).perform(click());
can you guide me solve this issue?
Thanks
Move gradle dependencies to one of the first steps
Hi guys, just a matter of suggestion I would recommend bring steps like add resource gradle dependency to one of the first TODO steps. The reason I am saying that is because for those not familiar with the IDE or even are not that good yet at predicting problems, walking along the steps with sintax problems popping up your code is not cool.
For instance exercise 4:
You can't get your code compiled at step 3 and 4 until your reach the step 9.
I know that is a very silly situation, but let's think as very beginner person.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.