I refactored my package name and put my CuteMainActivityin the package org.azurespot.cutemain.CuteMainActivity. Plus rearranged all my other classes. So now I get a red error on the .CuteMainActivity part in my Manifest, where the activity should launch.
I also changed the top package name of my Manifest to the new one: org.azurespot, and also changed my applicationID in my build.gradle file to the new package name org.azurespot too. Then I rebuilt, cleaned, and even tried invalidate and restart to my project but nothing is getting rid of this red error. I also tried to assign the new package/activity name to launch in my run configurations, and got this error:
Launching application: org.azurespot/org.azurespot.cutemain.CuteMainActivity.
DEVICE SHELL COMMAND: am start -n "org.azurespot/org.azurespot.cutemain.CuteMainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.azurespot/.cutemain.CuteMainActivity }
Error type 3
Error: Activity class {org.azurespot/org.azurespot.cutemain.CuteMainActivity} does not exist
One strange thing, is that my package name has the word (androidTest) beside it. Would that make things not work? Usually studio creates a regular package name and a package_name (androidTest), but in the refactoring, I only see this (androidTest) one.
I have been researching this problem for a while, but nothing seems to work. Any suggestions? Thank you.
Manifest.java
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.azurespot" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".CuteMainActivity" //This has a red error
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
LogCat after changed Manifest name to ".cutemain.CuteMainActivity"
1480-1480/org.azurespot E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: org.azurespot, PID: 1480
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.azurespot/org.azurespot.cutemain.CuteMainActivity}: java.lang.ClassNotFoundException: Didn't find class "org.azurespot.cutemain.CuteMainActivity" on path: DexPathList[[zip file "/data/app/org.azurespot-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.azurespot-2, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.azurespot.cutemain.CuteMainActivity" on path: DexPathList[[zip file "/data/app/org.azurespot-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.azurespot-2, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
You should change it to one of the followings:
android:name="org.azurespot.cutemain.CuteMainActivity"
or
android:name=".cutemain.CuteMainActivity"
Ah... the package name with (androidTest) was indeed the culprit. All of the above answers should have fixed things, but the final problem was that when I refactored (I have no idea how it happened), all of my new package names got put into my androidTest directory in the src folder, and nothing was in my main of my src folder. So when my app went looking for the main activity, it could not be found. The fix to this was to put the whole java folder back into the main folder (as it was empty for some reason), then restart the app and everything worked again. It was not necessary to delete the androidTest folder, and it seems fine that it's empty.
Related
I had developed app on android studio 3.0.1, but I got a error when I installed the apk to my cellphone.
Cellphone connect mac by usb, click run button
,the apk will installed and run no error. But if I copy the apk in finder (like this)
to cellphone and install it in phone, there will be an error "APK parsing error".
If install apk by "adb install xxx.apk" ,when open the app, it will crash and logcat as follow:
12-20 16:35:09.562 14658-14658/? I/art: Late-enabling -Xcheck:jni
12-20 16:35:09.562 14658-14658/? I/art: Reinit property: dalvik.vm.checkjni= false
12-20 16:35:09.614 14658-14658/com.xxx.xxx I/InstantRun: starting instant run server: is main process
12-20 16:35:09.620 14658-14658/com.xxx.xxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 14658
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm64, /data/app/com.xxx.xxx-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2695)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm64, /data/app/com.xxx.xxx-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1083)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2685)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
12-20 16:35:09.624 14658-14658/com.xxx.xxx I/Process: Sending signal. PID: 14658 SIG: 9
But if click Bulid>Build APK(s) , then copy the apk in same folder (this : apk)to cellphone, it will install and run with no error...
is it a bug in android studio?
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxx">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In new version VS, You shold use "Bulid Apk" menu option to generate the product apk :)
try with disable Instant Run . it find at
Run Goto File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run
before this uninstall previous app from device.
Trying to build and run an app in Android Studio 2.2.2 that does work in Eclipse. When I try to debug it (on a Samsung Galaxy tab 4) I get: (BTW is there any way to get this to come out more readably in StackOverflow?)
I/System.out: waiting for debugger to settle... I/System.out: debugger
has settled (1484) I/InstantRun: Instant Run Runtime started. Android
package is com.xxxxxxx.remote, real application class is null.
W/InstantRun: No instant run dex files added to classpath
D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.xxxxxxx.remote, PID: 1925
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.xxxxxxx.remote/com.xxxxxxx.remote.RemoteControlActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.xxxxxxx.remote.RemoteControlActivity" on path: DexPathList[[zip
file
"/data/app/com.xxxxxxx.remote-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2644)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1476)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxxxxxx.remote.RemoteControlActivity" on path:
DexPathList[[zip file
"/data/app/com.xxxxxxx.remote-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2634)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
...etc...
I've "xxxxx"'ed out a proprietary name. What do real application class is null and No instant run dex files added to classpath mean? Also I see the reference to "Unable to instantiate activity ComponentInfo" in a lot of similar questions - what does it mean?
The activity it can't find is declared in the manifest as...
<activity android:launchMode="singleTask"
android:label="#string/app_name"
android:windowNoTitle="false"
android:configChanges="orientation"
android:screenOrientation="landscape"
android:name=".RemoteControlActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I can't even hit a breakpoint at the beginning of the Activity, so how do I debug this?
You can disable InstantRun and see if the problem persists.
I am confused about the permissions section for IBM's MobileFirst GMS Push notifications found here. (Section 5)
https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/notifications/push-notification-native-android-applications/
I have added all of these permissions verbatim, but im getting an error saying i havn't added manifest permissions. Do i need to modify the package names in these permissions?
Is this activity built in?
<activity
android:name="com.worklight.androidnativepush.AndroidNativePush"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:launchMode="singleTask">
Here is the error logcat
07-25 23:24:48.285 17146-17146/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.companyname.hitch.mobilefirsttestapp, PID: 17146
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.companyname.hitch.mobilefirsttestapp/com.companyname.hitch.mobilefirsttestapp.push.PushActivity}: java.lang.RuntimeException: Your manifest is not allowed to work with push. Android Manifest Error: Missing permission in manifest: com.companyname.hitch.mobilefirsttestapp.permission.C2D_MESSAGE
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Your manifest is not allowed to work with push. Android Manifest Error: Missing permission in manifest: com.companyname.hitch.mobilefirsttestapp.permission.C2D_MESSAGE
at com.worklight.wlclient.api.WLPush.<init>(WLPush.java:180)
at com.worklight.wlclient.api.WLClient.getPush(WLClient.java:957)
at com.companyname.hitch.mobilefirsttestapp.push.PushActivity.onCreate(PushActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
When creating a MobileFirst-based Hybrid app with the Android environment, MobileFirst will be creating it based on a template with a set of predefined permissions and activities.
In a native application, you are the one creating it. MobileFirst only supplies you with the SDK and a set of integration instructions.
The activity that you mentioned in the question (taken from the tutorial page) is the activity of the sample application included in the tutorial. In your own app's AndroidManifest.xml you will see your app's name instead of "androidnativepush" (or rather need to create it).
Make sure not to use "androidnativepush" anywhere unless that is your app name.
I tried following the intstructions for adding a facebook login for my app.
https://developers.facebook.com/docs/facebook-login/android/v2.2
I did the step for Add the Login Button.
It displays properly on my screen however I get the following error when I click it:
Process: com.parse.starter, PID: 3073
Log in attempt failed: LoginActivity could not be started
at com.facebook.login.LoginManager.startLogin(LoginManager.java:382)
at com.facebook.login.LoginManager.logInWithReadPermissions(LoginManager.java:262)
at com.facebook.login.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:693)
at com.facebook.FacebookButtonBase$1.onClick(FacebookButtonBase.java:310)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Do I need to handle user clicks in my code. Somehow I thought this was inbuilt in the button. Thanks for the help.
For Facebook SDK 4+, you need the following in your manifest:
<activity android:name="com.facebook.FacebookActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
I'm getting following crash reports in Google Play developer console and Google Analytics:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp.package.here/com.google.android.gms.ads.AdActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdActivity" on path: DexPathList[[zip file "/data/app/com.myapp.package.here-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.package.here-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdActivity" on path: DexPathList[[zip file "/data/app/com.myapp.package.here-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.package.here-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
... 11 more
I'm using latest AdMob (through Google Play Services lib) API as documented here:
https://developers.google.com/mobile-ads-sdk/docs/
Relevant parts of config:
<application...>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
layout xml:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/adMobUnitId" />
code:
//onCreate()...
try {
adView = (AdView) activity.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(adRequest);
} catch (Exception e) {
Log.e("AdManager", "Unable to load ads", e);
}
//onResume()
adview.resume()
Looks like this only happens on some devices and working fine in emulator and real devices I have access to.
According to Google AdMob Ads Developer group new AdMob SDK should work on devices even if it does not have Google Play installed (btw one crash report is from Nexus7 2013 stock). So I assume it is not a problem...
Also as seen from Ad loading code it is in try/catch and looks like this exception happens even before my code gets executed. This is also seen from exception stack trace (no lines with my app package)
Anybody knows what could be the problem? Any help is appreciated!
Looks like problem has solved after updating Google Play Services lib to the latest version.