Я был занят моим приложением более недели, когда вдруг:
11-12 07:59:17.860 1653-1653/nl.test.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{nl.test.MyApp/nl.test.MyApp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "nl.test.myapp.MainActivity" on path: DexPathList[[zip file "/data/app/nl.test.myapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/nl.test.myapp-2, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "nl.test.myapp.MainActivity" on path: DexPathList[[zip file "/data/app/nl.test.MyApp-2.apk"],nativeLibraryDirectories=[/data/app-lib/nl.test.MyApp-2, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
вот мой AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nl.test.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="nl.test.myapp.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>
<activity android:name=".welcomewizard.WelcomeWizardIntroPage"
android:label="@string/app_name" />
<activity android:name=".welcomewizard.WelcomeWizardPage1"
android:label="@string/app_name" />
<activity android:name=".welcomewizard.WelcomeWizardPage2"
android:label="@string/app_name" />
<activity android:name=".welcomewizard.WelcomeWizardPage3"
android:label="@string/app_name" />
<activity android:name=".welcomewizard.WelcomeWizardPage4"
android:label="@string/app_name" />
<activity android:name=".welcomewizard.WelcomeWizardFinishPage"
android:label="@string/app_name" />
<activity android:name=".CompanySelectorActivity"
android:label="@string/compsel_actionbarlabel" />
</application>
</manifest>
это происходило после некоторых проблем с моим R.java(идентификатором для неверных представлений), после восстановления проекта эта проблема произошла
Я уже пробовал Invalidate Cashes/restart в меню файлов IDE
Обновление 14:51: это мой файл compiler.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
Мой файл MainActivity.java(\ src\main\java\nl\test\myapp\MainActivity.java):
package nl.test.myapp;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.widget.RelativeLayout;
import nl.test.myapp.welcomewizard.WelcomeWizardIntroPage;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setBackground(R.drawable.background_grey);
Intent intent = new Intent(this, WelcomeWizardIntroPage.class);
startActivity(intent);
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setBackground(int drawable){
int currentApiVersion = android.os.Build.VERSION.SDK_INT;
if(currentApiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN){
RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_main);
layout.setBackground(getResources().getDrawable(drawable));
}
}
}