RuntimeException : Didn't find class on path: DexPathList - java

Yesterday everything worked fine with my project, but today I receive very weird errors :
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.redonbas/com.example.redonbas.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.redonbas.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.redonbas-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.redonbas-2, /vendor/lib, /system/lib]]
My AndroidManifest :
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
MainActivity is in correct package:
I refered to the problem but I copied all the File System of the project to the new, but that didn't help. I also created new project with another package and manually copied all the stuff from the old project there - the problem still remains!
What's wrong with it?

Uncheck your Android Dependencies and Android Private Libraries Checkboxes.

Yes, the problem was in past SherlockActionBar and its android-support library implementing .

Related

Installation did not succeed in Android version 12 - API 31 and above

I tried to install my application in an Android version 12. I added the android:exported for each activity, receiver and filters. This error occurs
Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
List of apks:
[0] 'C:\Users\Code\MyApp\app\build\outputs\apk\debug\app-debug.apk'
Installation failed due to: 'Failed to commit install session 366841949 with command package install-commit 366841949. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl366841949.tmp/base.apk (at Binary XML file line #392): androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'
Retry
Failed to launch an application on all devices
The merged manifist displays these errors
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 26
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. muapp.app main manifest (this file), line 33
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 40
This is the test AndroidManifest.XML file that causes the errors
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidx.test.core" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<application>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
These are the test dependencies I'm using
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
androidTestImplementation('androidx.test:runner:1.4.0')
androidTestImplementation('androidx.test:rules:1.4.0')
The problem occurs in the test package and its auto generated. How to fix it?
I tried multiple solutions to fix the problem but nothing seems to fix it.
These are some solutions I looked into but didn't work for me.
Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier
The error was fixed by changing this dependency version androidx.fragment:fragment-testing
from version 1.3.5
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
to version 1.4.0
debugImplementation 'androidx.fragment:fragment-testing:1.4.0'
This answer helped me fix the error https://stackoverflow.com/a/71605255/9770844

Issues running any new android project - Default Activity Not found / Invalid Java package

total noob with lots of issues with Android Studio.
Default Activity error
Invalid java package name
Getting a Default Activity error on any app or new project I run - below is an example of the AndroidManifest.xml
"Error running 'app': Default Activity not found"
I have checked more than 100 times I am using the right package names and that my activity is declared in the android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.coleary.change;">
<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="com.example.coleary.change.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="#string/TicTacToe"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The package name is the same in the java code:
package com.example.coleary.change;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
// use tictactoe code in our code for a new game
private TicTacToeGame mGame;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.example.coleary.change.R.layout.activity_main);
//this activity(game) is a context within a main activity
mGame= new TicTacToeGame(this);
}
}
When I run the project I get the following error also:
Package 'com.example.coleary.change;' from AndroidManifest.xml is not a valid Java package name as 'change;' is not a valid Java identifier.
I have changed the package name through Refactoring to 5 different names to no avail.
I have spent over 15 hours hours trying to troubleshoot these issues and because I have the same issue on multiple projects / packages and apps I am completely stuck - any help really appreciated!
Remove the semi-colon after change in your AndroidManifest. Package names can't contain semi-colons.

GcmReceiver class not found in Quick Start Sample in GCM DOCS

I'm trying to develop an app with GCM,
so I downloaded Sample project made by Google here
: https://developers.google.com/cloud-messaging/android/start
At the manifest of this project, there is code for GcmReceiver below:
<!-- [START gcm_receiver] -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="gcm.play.android.samples.com.gcmquickstart" />
</intent-filter>
</receiver>
<!-- [END gcm_receiver] -->
But At java package, there is no class named GcmReceiver below is the picture the sample project I have show me:
Just with the manifest xml file, is that GcmReceiver working well?
You have to add at least Play Services 7.5.0 to your project.
I suggest you to add latest library vs 8.3.0
Here's link for gradle users:
compile "com.google.android.gms:play-services:8.3.0"

NoClassDefFoundError in Eclipse

So essentially I've been making a game using libgdx and just recently I started to try and add Google Play Game Services and So I tried my hand at it and it seems as though I have completely messed up my .xml file I've tried looking at questions such as How do I resolve this Java Class not found exception? and NoClassDefFoundError - Eclipse and Android, but to no avail.
Here is the runtime error I am recieving.
02-19 19:25:17.772: E/AndroidRuntime(25746): FATAL EXCEPTION: main
02-19 19:25:17.772: E/AndroidRuntime(25746): Process: com.coppercow.minerman, PID: 25746
02-19 19:25:17.772: E/AndroidRuntime(25746): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.coppercow.minerman/com.coppercow.minerman.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.coppercow.minerman.MainActivity" on path: DexPathList[[zip file "/data/app/com.coppercow.minerman-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.coppercow.minerman-2, /vendor/lib, /system/lib]]
The class Name is MainActivity.Java and it is in the src file. I understand that this is done because of one of two things: My .class file, or the .xml file. So here is also my .xml file just in case what I have done wrong is there and not in fact in any .class file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.coppercow.minerman"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
However I've messed around with this xml file quite a lot and so I do not believe it is in here and that My whole problem has to be in some .class file somewhere, but I don't even understand how to access those from eclipse from going off of other questions asked here on StackOverflow.
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.
Hope this helps.

AndroidManifest.xml errors

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android">
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:name=".hba1c" android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I'm trying to learn Java and need some help with AndroidManifest.xml
My little hello world project is working code-wise, but I'm confused with making changes to the manifest. Specifically, in the code above package name is "com.android" and in data/app my app shows up as com.android-1.apk. When I try to change it to something like com.jocala or com.jocala.hba1c I get package R does not exist errors through my compile, which fails.
What changes do I need to make? Anything else here that is glaringly bad?
I am working using Ant, VI and the Linux console, no Eclipse.
You should change the package of the java code, let it in accordance with the package which you defined in the manifest file.
The manifest holds meta-data corresponding to your android application. Hence, if you needs changes in the package name, make the changes in the java files, change the package name there, there is no sense making a change here. The only changes that are majorly done in the manifest are activity related(for beginners). Have a read here.

Categories