This is a exercise repository for Developing Android Apps. You can learn more about how to use this repository here
udacity / ud851-exercises Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
This is a exercise repository for Developing Android Apps. You can learn more about how to use this repository here
Hello,
I'm following the guides from https://classroom.udacity.com/courses/ud851/lessons/93affc67-3f0b-4f9b-b3a4-a7a26f241a86/concepts/ebe17315-13a6-452b-828e-aa3de89c4c09#
and quite surprised that this repository have different folder count.
There is No Lesson01-Favorite-Toys/T01.02-Exercise-DisplayToyList
On Exercise: Data Design, the second question is:
What is the variable for the column that contains the description of the task?
Answering that question with the correct variable name (COLUMN_DESCRIPTION) gives me an error. The other two answers work as intended.
There are no spaces or other extra characters, the name was copied from the code.
The exercise T02.02 where you learn to add a menu is not available.
There seems to be a bug or misinterpretation of what isCharging should mean to the Android Core Development
https://developer.android.com/reference/android/os/BatteryManager.html#isCharging()
Even if the battery is full and the device is still connected to power I believe this method should still return true which is not the case in the emulator nor in the most recent Android OS version. These two conditions should not be treated as mutually exclusive as it seems to be the case.
My guess is that the main purpose of the BatteryManager service would be to adequately track changes related battery and keep a correct state for the user to query based on an effective model which it does not seem to be case for this matter.
when i run the app. throws exception
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.datafrominternet, PID: 14597
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:231)
at com.example.android.datafrominternet.utilities.NetworkUtils.getResponseFromHttpUrl(NetworkUtils.java:75)
at com.example.android.datafrominternet.MainActivity.makeGithubSearchQuery(MainActivity.java:63)
at com.example.android.datafrominternet.MainActivity.onOptionsItemSelected(MainActivity.java:80)
at android.app.Activity.onMenuItemSelected(Activity.java:2908)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:408)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:198)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113)
at android.support.v7.app.AppCompatDelegateImplV9.onMenuItemSelected(AppCompatDelegateImplV9.java:675)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:959)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:623)
at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:154)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Error:com.android.builder.internal.aapt.AaptException: Failed to crunch file C:\Users\jason\AndroidStudioProjects\ud851-Exercises-student\ud851-Exercises-student\Lesson01-Favorite-Toys\T01.03-Solution-AddScrolling\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.1.1\res\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png into C:\Users\jason\AndroidStudioProjects\ud851-Exercises-student\ud851-Exercises-student\Lesson01-Favorite-Toys\T01.03-Solution-AddScrolling\app\build\intermediates\res\merged\debug\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png
I'm getting a very erratic bahaviour when testing both my code and the solution on the simulator (Nexus 5X - Android 7.0), I've double checked it's "charging" but for some reason it doesn't apear to be working.
On the other hand, if tested on a physical device (Note 3 - Android 4.4) it works perfectly.
Is this somehow expected or is it a known issue?
QUIZ QUESTION
Check the following choices that would make just the treble triangle and bass circle visible, in red.
The default value of private boolean showMid;
is false inside VisualizerView
so one doesnot need to explicitly call mVisualizerView.setShowMid(false);
This means only three choices are correct.
refers to (e.g.): class NotificationUtils.java
, method remindUserBecauseCharging()
, lines 84-85
As we are already using the NotificationCompat.Builder
class, wouldn't it make sense to also use the NotificationManagerCompat (instead of the framework's NotificationManager)?
like so:
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
On second thought, using NotificationManagerCompat
instead of NotificationManager
would demand to re-do the respective course videos and instructor notes, too (on quite a few occurrences), so maybe this would make more sense for a future version of this course...
Kind regards!
After update to v2.3, Android Studio gives NPE on creating a new activity. In fact, all the options in the right click on the 'app' folder -> new menu from AIDL to XML give the same exception, 'Null Pointer Exception: null
'. On clicking on it, a window titled 'IDE Fatal Errors' appears, with the message 'Exception in plugin Android Support', with a stack trace:
null
java.lang.NullPointerException
at com.android.tools.idea.actions.NewAndroidComponentAction.actionPerformed(NewAndroidComponentAction.java:121)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:156)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:211)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$2(ActionMenuItem.java:304)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:905)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:284)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:112)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.access$300(TransactionGuardImpl.java:40)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:113)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:123)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:109)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:513)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:45)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:795)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:627)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
This error doesn't occur in a new project, or other old projects, only with the projects of this repo.
In current code, Uri builder has been used which puts a '/' after the 'geo:' part (as it has been passed as path). This leads to the app switching to the maps app, but not querying the address given, and instead opening up at default location, in a 'ready to search' state.
Maybe use something like
Uri mapUri = Uri.parse("geo:0,0?q="+Uri.encode(address));
public NumberViewHolder(View view) {
super(itemView);
listItemNumberView = (TextView) itemView.findViewById(R.id.tv_item_number);
}
itemView should be just 'view' (or other way around).
Error:(1, 0) The android gradle plugin version 2.3.0-alpha1 is too old, please update to the latest version.
Simply adding to AndroidManifest.xml
seems to not be enough to be able to make a request.
The only way I got this to work was to add the following code prior to calling the getResponseFromHttpUrl method
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
I didn't see this issue reported and this was the only way I got the request to return results, otherwise an error would be thrown.
android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
Please advise on the best way to proceed regarding this issue.
The instruction in MainActivity.java
is confusing with the first and last description line Do 2 - 7 in menu.xml. It should be changed to Do 2 - 7 in main.xml.
// Do 2 - 7 in menu.xml ///////////////////////////////////////////////////////////////////////
// TODO (2) Create a menu in xml called main.xml
// TODO (3) Add one menu item to your menu
// TODO (4) Give the menu item an id of @+id/action_search
// TODO (5) Set the orderInCategory to 1
// TODO (6) Show this item if there is room (use app:showAsAction, not android:showAsAction)
// TODO (7) Set the title to the search string ("Search") from strings.xml
// Do 2 - 7 in menu.xml ///////////////////////////////////////////////////////////////////////
Error:com.android.builder.internal.aapt.AaptException: Failed to crunch file C:\Users\jason\AndroidStudioProjects\ud851-Exercises-student\ud851-Exercises-student\Lesson01-Favorite-Toys\T01.01-Exercise-CreateLayout\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.1.1\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png into C:\Users\jason\AndroidStudioProjects\ud851-Exercises-student\ud851-Exercises-student\Lesson01-Favorite-Toys\T01.01-Exercise-CreateLayout\app\build\intermediates\res\merged\debug\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png
Hello,
I'm following the guide from "Exercise: Create a RecyclerView" and the Diff link opens a Compare Changes page that display the following message:
"There isn’t anything to compare.
We couldn’t figure out how to compare these references, do they point to valid commits?"
Attached a screenshot of the issue ...
Thanks for your time and efforts
Error while cloning github repository. Error happen after fork the repository and tried clone into my machine (my OS is Windows 10).
Error:
"Cloning into 'ud851-Exercises'...
remote: Counting objects: 4160, done.
remote: Total 4160 (delta 0), reused 0 (delta 0), pack-reused 4159
Receiving objects: 100% (4160/4160), 3.70 MiB | 366.00 KiB/s, done.
Resolving deltas: 100% (1807/1807), done.
Checking connectivity... done.
error: unable to create file Lesson06-Visualizer-Preferences/T06.01-Exercise-SetupTheActivity/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals/AudioInputReader.java: Filename too long
error: unable to create file Lesson06-Visualizer-Preferences/T06.01-Exercise-SetupTheActivity/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals/TrailedShape.java: Filename too long
error: unable to create file Lesson06-Visualizer-Preferences/T06.01-Exercise-SetupTheActivity/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals/VisualizerView.java: Filename too long
error: unable to create file Lesson06-Visualizer-Preferences/T06.01-Solution-SetupTheActivity/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals/AudioInputReader.java: Filename too long
error: unable to create file Lesson06-Visualizer-Preferences/T06.01-Solution-SetupTheActivity/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals/TrailedShape.java: Filename too long
error: unable to create file Lesson06-Visualizer-Preferences/T06.01-Solution-SetupTheActivity/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals/VisualizerView.java: Filename too long
fatal: cannot create directory at 'Lesson06-Visualizer-Preferences/T06.02-Exercise-MakeAPreferenceFragment/app/src/main/java/android/example/com/visualizerpreferences/AudioVisuals': Filename too long"
i tried to make the GithubQueryTask AsyncTask to fetch the data every time it gets me error message.
when i tried to put "else" statment in the onPostExecute method like this
@Override protected void onPostExecute(String githubSearchResults) { mLoadingIndicator.setVisibility(View.INVISIBLE); if (githubSearchResults != null && !githubSearchResults.equals("")) { showJsonDataView(); mSearchResultsTextView.setText(githubSearchResults); }else showErrorMessage(); }
the code worked correctly and it fetched the requested data
Followed instructions in lesson 1. Replaced ConstraintLayout with FrameLayout and in the designer this error message appeared: "The following classes could not be found: android.support.contraint.FrameLayout". However, the project would still build and deploy, but crashed at runtime with a similar message.
I was able to resolve the issue by deleting the activity_main.xml and re-adding a new activity through the IDE. I noticed that when it added to the FrameLayout, it did not specify the fully qualified class name "android.support.contraint.FrameLayout". Rather it simply specified "FrameLayout". I opened the corresponding solution project and noticed it also did not have the fully qualified name. This must be an issue that is only in the exercize file.
Imported T02.01 - Exercize.. built, got this:
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha2.
Required by:
project :app
The first TODO in T05a.03 reads:
// TODO (1) Declare and instantiate an ArrayList of Strings called mLifecycleCallbacks
It should read:
// TODO (1) Declare and instantiate a static ArrayList of Strings called mLifecycleCallbacks
This code doesn't work if the ArrayList isn't static.
This TODO should be in Android section
TODO (3) in VisualizerActivity.java, starting at line 122, should be changed from:
// TODO (3) In visualizer_menu.xml create a menu item with a single item. The id and title
// should be saved in strings.xml, it should never be shown as an action,
// orderInCategory should be 100
to:
// TODO (3) In visualizer_menu.xml create a menu item with a single item. The id should be
// action_settings and the title should be saved in strings.xml,
// it should never be shown as an action,
// orderInCategory should be 100
Kind regards,
ikrotzky
In the NetworkUtilit.java class
*** Builds the URL used to query Github.
*
* @param githubSearchQuery The keyword that will be queried for.
* @return The URL to use to query the weather server.(the return value for this case is not the url for the weather server it is for the gitHub )
/*
public static URL buildUrl(String githubSearchQuery) {
Uri builtUri = Uri.parse(GITHUB_BASE_URL).buildUpon()
.appendQueryParameter(PARAM_QUERY, githubSearchQuery)
.appendQueryParameter(PARAM_SORT, sortBy)
.build();
URL url = null;
try {
url = new URL(builtUri.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
}
return url;
}
On Adroid Studio 2.2.3 when I choose a folder Exercise (for example the 'T01.01-Exercise-CreateLayout'), and I try to import it from File menu -> Import project... Android Studio shows a progress dialog but the project loading never ends, so I have to kill the application, create a empty project and copy/paste everything manually. Could be an Android studio incompatibility problem for old projects?.
I appreciate all the effort you make to create these courses, they are very good, but this little detail makes the learning process a little tedious, I hope there is a solution for this. thank'u so much.
The example solution is not working the way it should. It opens Google Maps, but not at the location specified.
In the example solution, the query parameter is added using the .query()
method of Uri.Builder
. This has no effect. The documentation specifies that the query parameter must have a key of "q".
So the solution is to use the .appendQueryParameter()
method, specifying "q" as the key:
public void onClickOpenAddressButton(View v) {
Uri.Builder builder = new Uri.Builder();
builder.scheme("geo")
.path("0,0")
.appendQueryParameter("q", "Mountain View");
showMap(builder.build());
}
The answer to the JSON question on
https://classroom.udacity.com/courses/ud851/lessons/e5d74e43-743c-455e-9a70-7545a2da9783/concepts/28ad45a2-c02f-4e95-9785-ac47b8024ae6#
is not valid JSON
It has misplaced commas.
Change
{
"temp": {
"min":"11.34",
"max":"19.01",
}
"weather": {
"id":"801",
"condition":"Clouds",
"description":"few clouds",
}
"pressure":"1023.51",
"humidity":"87"
}
to
{
"temp": {
"min":"11.34",
"max":"19.01"
},
"weather": {
"id":"801",
"condition":"Clouds",
"description":"few clouds"
},
"pressure":"1023.51",
"humidity":"87"
}
EDIT: Closed because this was posted on the wrong repo.
Error occurs during Gradle Build
Fixed by adding to the Gradle file:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.1.1'
}
}
Hi,
I really like the course, you are doing a great job!
I found an (let's say) error in the TODO:
// action_settings, the id and title should be saved in strings.xml, the item should never
I think the ID should not be in the strings.xml. You did not put it into the strings.xml in the solution either.
Would you like me to create a PR if you confirm that this is really an error? Thanks!
The COMPLETED (3) text should be changed
from:
Create a static final String called ...
to:
Create a private static final int called ...
links to issue #38
I got a runtime error in Lesson02-GitHub-Repo-Search / T02.04-Solution-ConnectingToTheInternet while pressing the Search button.
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.datafrominternet, PID: 3471 android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303) at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74) at java.net.InetAddress.getAllByName(InetAddress.java:752) at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187) at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156) at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98) at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java) at com.example.android.datafrominternet.utilities.NetworkUtils.getResponseFromHttpUrl(NetworkUtils.java:76) at com.example.android.datafrominternet.MainActivity.makeGithubSearchQuery(MainActivity.java:68) at com.example.android.datafrominternet.MainActivity.onOptionsItemSelected(MainActivity.java:85) at android.app.Activity.onMenuItemSelected(Activity.java:3204) at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:408) at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:198) at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113) at android.support.v7.app.AppCompatDelegateImplV9.onMenuItemSelected(AppCompatDelegateImplV9.java:675) at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822) at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:959) at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:623) at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:154) at android.view.View.performClick(View.java:5610) at android.view.View$PerformClick.run(View.java:22265) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Seems following code could resolve the problem:
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
In this line the resource ID should be R.color.colorPrimary
.
File name: activity_main.xml
TODO (11) Make this TextView a child of the FrameLayout the you added above
TODO (11) Make this TextView a child of the FrameLayout that you added above
I got the following error message when I imported T01.01-Exercise-CreateLayout.
Error:Unknown host 'services.gradle.org'. You may need to adjust the proxy settings in Gradle.
In T06.01-Exercise-SetupTheActivity
TODO 1 create new SettingsActivity, Android Studio reports error when I click finish button on new activity window, new Activity Dialog not closing (I can move it but not close it).
It happens only with projects from this repo, no problems while creating new activity's in my projects.
I got all latest tools from stable channel.
IDE adds over 2000 lines off error message to log file
here some of them:
2017-02-05 02:26:44,053 [ 85794] WARN - rendering.ConfigurationMatcher - 'default' is not a best match for any device/locale combination for file://X:/ud851-Exercises-student/Lesson06-Visualizer-Preferences/T06.01-Exercise-SetupTheActivity/app/src/main/AndroidManifest.xml.
Displaying it with
, , , Left To Right, sw384dp, w384dp, h640dp, Normal Screen, Short screen aspect ratio, Not Round screen, Portrait Orientation, Normal, Day time, X-High Density, Finger-based touchscreen, Soft keyboard, No keyboard, Hidden navigation, No navigation, Screen resolution 1280x768, API Level 25
which is compatible, but will actually be displayed with another more specific version of the layout.
2017-02-05 02:26:44,055 [ 85796] WARN - rendering.ConfigurationMatcher - 'default' is not a best match for any device/locale combination for file://X:/ud851-Exercises-student/Lesson06-Visualizer-Preferences/T06.01-Exercise-SetupTheActivity/.idea/misc.xml.
Displaying it with
, , , Left To Right, sw384dp, w384dp, h640dp, Normal Screen, Short screen aspect ratio, Not Round screen, Portrait Orientation, Normal, Day time, X-High Density, Finger-based touchscreen, Soft keyboard, No keyboard, Hidden navigation, No navigation, Screen resolution 1280x768, API Level 25
which is compatible, but will actually be displayed with another more specific version of the layout.
2017-02-05 02:26:44,079 [ 85820] ERROR - freemarker.runtime - Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:98)
...................................................
2017-02-05 02:26:44,092 [ 85833] ERROR - llij.ide.plugins.PluginManager - com.android.tools.idea.templates.FreemarkerUtils$TemplateProcessingException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (print stack trace for 1 more):
==> ${manifestDir} [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 37]
java.lang.RuntimeException: com.android.tools.idea.templates.FreemarkerUtils$TemplateProcessingException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (print stack trace for 1 more):
==> ${manifestDir} [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 37]
Caused by: com.android.tools.idea.templates.FreemarkerUtils$TemplateProcessingException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (print stack trace for 1 more):
==> ${manifestDir} [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 37]
.......................................
Caused by: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (print stack trace for 1 more):
==> ${manifestDir} [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 37]
.................................
2017-02-05 02:26:44,095 [ 85836] ERROR - llij.ide.plugins.PluginManager - Android Studio 2.2.3 Build #AI-145.3537739
2017-02-05 02:26:44,095 [ 85836] ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_76-release
2017-02-05 02:26:44,096 [ 85837] ERROR - llij.ide.plugins.PluginManager - VM: OpenJDK 64-Bit Server VM
2017-02-05 02:26:44,096 [ 85837] ERROR - llij.ide.plugins.PluginManager - Vendor: JetBrains s.r.o
2017-02-05 02:26:44,096 [ 85837] ERROR - llij.ide.plugins.PluginManager - OS: Windows 10
2017-02-05 02:26:44,096 [ 85837] ERROR - llij.ide.plugins.PluginManager - Last Action: template.create.ActivityEmpty Activity
I have clone this project and run through Android Studio. But not able to run it as build/run button are disable.
// TODO (5) Implement OnClickListener in the ForecastAdapterViewHolder class
should be
// TODO (5) Implement OnClickListener in the NumberViewHolder class
// TODO (6) Override onClick, passing the clicked item's position (getAdapterPosition()) to mClickHandler via its onListItemClick method
should be
// TODO (6) Override onClick, passing the clicked item's position (getAdapterPosition()) to mOnClickListener via its onListItemClick method
I am getting this error after importing the project .
Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file C:\Users...\Desktop\ud851-Exercises-student_2\ud851-Exercises-student\Lesson02-GitHub-Repo-Search\T02.01-Exercise-CreateLayout\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png
into
C:\Users...\Desktop\ud851-Exercises-student_2\ud851-Exercises-student\Lesson02-GitHub-Repo-Search\T02.01-Exercise-CreateLayout\app\build\intermediates\res\merged\debug\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png
After removing ConstraintLayout and its attributes, we don't need
xmlns:app="http://schemas.android.com/apk/res-auto"
Should add another TODO to override the onDestory
method that close the cursor
@Override
protected void onDestroy() {
super.onDestroy();
// Don't forget to close your cursor!
mData.close();
}
I'm using a fresh install of Android Studio 2.2.3 and I am recieving this error when I try to build the first exercize: "Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)"
The TODO (3) text should be changed
from:
Create a static final String called ...
to:
Create a private static final int called ...
BTW: This should also be fixed in the related course video
Damned Copy&Paste...
😄
linked with: Issue #34
COMPLETED (3) in visualizer_menu.xml
, starting at line 3
, should be changed from:
// COMPLETED (3) In visualizer_menu.xml create a menu item with a single item. The id and title
// should be saved in strings.xml, it should never be shown as an action,
// orderInCategory should be 100
to:
// COMPLETED (3) In visualizer_menu.xml create a menu item with a single item. The id should be
// action_settings and the title should be saved in strings.xml,
// it should never be shown as an action,
// orderInCategory should be 100
Kind regards,
ikrotzky
gradle-wrapper.properties have;
distributionUrl=https://services.gradle.org/distributions/gradle-3.2.1-all.zip
but the latest android studio support:
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
should change it in the code or change settings -> build, Execution, Deployment -> Gradle mark "Use default gradle wrapper"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.