Example NetworkUsage Android Code Crashes On Startup? - android

I am trying to run the example application in the networkusage.zip file on the Android Developers website (location: http://developer.android.com/training/basics/network-ops/index.html).
I have not made any changes to the code whatsoever. However, it crashes immediately on startup. I have tried setting a breakpoint in the onCreate method of the main activity, but it never gets there....just crashes right away.
I am just starting with Android, but I been able to complete other training sessions and run other example apps, so I believe my configuration works. I am running Windows 7, with Eclipse Juno and the very latest JDK and Android SDK/ADT (both downloaded about a week ago).
I am using an emulator targeting Android 4.1 (API 16).
The emulator shows a messages that says Unfortunately, NetWork Usage has stopped working.
Any help would be greatly appreciated!!

In AndroidManifest.xml file, for this project, substitute absolute android:name for NetworkActivity with relative one.
In other words, change this line:
android:name="com.example.networkusage.NetworkActivity"
to look like this:
android:name=".NetworkActivity"
The problem was that NetworkActivity is not in com.example.networkusage (as was in AndroidManifest.xml file), but in com.example.android.networkusage package. Thus, Android couldn't find the class on runtime.

Related

Failed to open directory Xamarin Forms

I have recently created a HelloWorld project with Xamarin Forms to develop a mobile app. But, I don't know what happen but I cannot launch the app with Android Device Manager or even my own phone, not even the first time. This is the error:
I am using android version 10.0 to compile and for the device manager the version 10.0 also. At the manifest I also have version 10.0 for Android minimum version required and Android target version. I guess the version is not the problem, but I don't know what could be because, I haven't programmed anything yet. So I don't understand why the error is "The system cannot fint the specified file". I check the access route with File Explorer of Windows and there is the directory.
Unbelievable. My windows 10 user has an accent mark on the name: Adrián. But the problem was with the path of the project, because I change the name to: Adrian, but the path was still having the accent mark: C:\Users\Adrián. So that is very probably the problem. I know I could change the username from the path, but I think it is a bit difficult than to create a new user, besides, I don't want more problems with another programs installed. I created a new windows user, obviously, without any weird character and then I could work with Xamarin Forms. I think you learn a new thing every day.
Had the same issue when my project was called Städteam1. I created a new solution and project named Stadteam1 and it works right away. So I guess avoid using any letters that aren't part of standard English in any of the folder or filenames.

How to start developing app for Google Glass?

I am working on a Google glass Android app. I have installed the glass development kit (GDK) in Android SDK. Now I created a glass project using Android Studio (Version 3.3.2). The newly created project is showing an error "Default Activity not found" in run->edit configuration.
Please refer the screenshot for the error.
1.
And 2. By clicking run->Edit Configuration in menu.
I have searched a lot on Google and found many articles regarding the same. All are suggested to set the edit configurations option like below.
Module: app
Package: Deploy default APK
Activity: Launch default Activity
Target Device: USB Device
I did the same, but no one is working for me. After spending the whole day to make it work, I came here. This error is due to the Launcher activity, because there is no launcher activity in Google glass project instead it uses Voice Trigger intent filter. It is similar to wearable apps they also don't have the launcher activity.
Android Studio won't let you use a standard run configuration without specifying a launcher in the manifest.
You could try using the gradle command line instead:
./gradlew installDebug
In case you haven't resolved the issue. I came across similar issue before, two ways worked for me:
Choose "Nothing" as the option. You will be able to run the app manually on the Glass, but your debugger won't work straight away. You have to manually attach the debugger to the process. You may also have to use logcat if there is a bug in the launching process.
Specify an activity (whichever is associated with voice trigger).
Also, I noticed that you created the app using Kotlin. Kotlin activity didn't work in my case, throwing exceptions associated with nullable var when resuming the activity. Non-activity classes worked fine. Please let me know if Kotlin activity worked in your case.

Hide application shortcut

I am trying to make an application of which I am trying to hide the launcher shortcut. The reason for this is so I could use this apps as a module / extension for another app without it being visible or cluttering the launcher environment (ie. having this app on your phone will unlock partial functionality in another app). I have been looking into how to do this for a while now, but I can't find a proper solution.
I have read a 'solution' to this issue that tells me to remove <category android:name="android.intent.category.LAUNCHER" /> from the AndroidManifest.xml file. This however results in Android Studio not being able to build or run the app at all, giving me an error that says Default Activity not found (I have tried this with a fresh project and an empty activity).
I am trying to develop this app on my personal device which is a Huawei P9 Lite, running android 6.0
Is there a way to do this?
EDIT
I've read somewhere that Google has removed the ability to uninstall shortcuts since android 6.0. Although it doesn't really say anything about hiding shortcuts for your application, I went ahead and assumed it's part of the same security fix.
Is there a way to do this for the newest platform versions?
I have read a 'solution' to this issue that tells me to remove from the AndroidManifest.xml file.
That is the correct answer.
This however results in Android Studio not being able to build or run the app at all, giving me an error that says Default Activity not found (I have tried this with a fresh project and an empty activity).
Well, it may not make sense to run it. After all, you say that this app is a plugin to some other app. In many cases, a plugin itself cannot run independently (e.g., you cannot run a browser plugin except via the hosting browser).
That being said, you can edit your run configuration via Run > Edit Configurations, and choose what you want to have happen when you run the module:
The run configuration for an app module defaults to "Default Activity", but you can choose something else (e.g., "Specific Activity").
I've read somewhere that Google has removed the ability to uninstall shortcuts since android 6.0.
That answer is unrelated to your question.

MyEclipse: Changing Android codes takes no effect

I know this is a rare question. Even if there are people using MyEclipse for Android development is doubted :(
The annoying thing is that after I modified my Android project (like an Activity class of a xml file), the project remained the same as it was when I imported it.
I thought there is an important feature that demonstrates this error: When I run my Android project and the console reported that "Activity not started, its current task has been brought to the front". This line occurs because the project didnt changed while as a matter of fact I did change the project and saved it.
Is there anyone has the same problem like me?
-------------add in Oct. 28-------------------
This was what I did: first, I modified one of my activities by commenting out the Toast functions; and then, I ran it however the Toast line still showed on my Genymotion emulator

Cant add AdMob on eclipse

Im just tryng to put admob (4.3.1) on a android app (3.3, api 10) on eclipse (Version: 3.7.2)
following the google tutorial, at the start i have a error on
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
and then in Adding a com.google.ads.adview... I just didint know what to do, I tried 2 or 3 times, but it's not clear to me if I have to delete the Import from my project and put that or put below or above. I downloaded the sample but I seem to have errors in the activity.
So I just tried to create a banner XML and with no problems. I saved as a .apk, put on my phone (the device what I gave the device ID for test) and it just won't open, it forces close every time I try. I have almost 10 free apps on the market just waiting for ads.
Your problem is that api 10 is version 2.3.3, not 3.3. The screenSize and smallestScreenSize configChanges required by AdMob were not introduced into the Android framework until Android 3.2 (api 13). So if your project.properties has something lower than android-13, your app simply won't compile.
As for adding the AdView, I'm not sure I understand your problem. The example code is open-sourced here. Perhaps you could point to the line that is giving you issues.

Categories

Resources