需要你的帮助!
我是Android新手,出于某种原因我的应用程序停止工作并在启动时崩溃。
我不确定它是否相关,但我已将maven添加到项目中。 这是错误日志:
06-23 14:32:18.380: E/AndroidRuntime(1775): FATAL EXCEPTION: main
06-23 14:32:18.380: E/AndroidRuntime(1775): Process: com.app.test, PID: 1775
06-23 14:32:18.380: E/AndroidRuntime(1775): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.app.test/com.test.activities.SplashActivity}: java.lang.ClassNotFoundException: Didn't find class "com.test.activities.SplashActivity" on path: DexPathList[[zip file "/data/app/com.app.test-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.ActivityThread.access$800(ActivityThread.java:151)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.os.Handler.dispatchMessage(Handler.java:102)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.os.Looper.loop(Looper.java:135)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.ActivityThread.main(ActivityThread.java:5257)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.reflect.Method.invoke(Native Method)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.reflect.Method.invoke(Method.java:372)
06-23 14:32:18.380: E/AndroidRuntime(1775): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
06-23 14:32:18.380: E/AndroidRuntime(1775): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-23 14:32:18.380: E/AndroidRuntime(1775): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.test.activities.SplashActivity" on path: DexPathList[[zip file "/data/app/com.app.test-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-23 14:32:18.380: E/AndroidRuntime(1775): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
06-23 14:32:18.380: E/AndroidRuntime(1775): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
06-23 14:32:18.380: E/AndroidRuntime(1775): ... 10 more
06-23 14:32:18.380: E/AndroidRuntime(1775): Suppressed: java.lang.ClassNotFoundException: com.test.activities.SplashActivity
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.Class.classForName(Native Method)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
06-23 14:32:18.380: E/AndroidRuntime(1775): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
06-23 14:32:18.380: E/AndroidRuntime(1775): ... 13 more
06-23 14:32:18.380: E/AndroidRuntime(1775): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
这是清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<uses-permission
android:name = "android.permission.INTERNET"/>
<uses-permission
android:name = "android.permission.BLUETOOTH_ADMIN"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.activities.SplashActivity"
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="com.test.activities.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.test.activities.MainMenuActivity"
android:label="@string/title_activity_main_menu" >
</activity>
</application>
这是活动:
public class SplashActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread StartTimer = new Thread(){
public void run(){
try {
sleep(2000);
Intent main = new Intent(SplashActivity.this, MainActivity.class);
startActivity(main);
finish(); //kills the current activity
}
catch (InterruptedException ex){}
}
};
StartTimer.start();
}
}
这是pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>mockwebserver</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
</project>
这里还有构建路径设置:
目录结构:
答案 0 :(得分:0)
我知道Maven构建系统等待一些修补,检查你的项目,你的来源应该位于以下地方:
在你的情况下/ src / main / java / com / test。
你的项目是否有这样的结构?
我还建议将groupid命名为“com.test”