更新到java 8应用程序后不启动。 gradle build正常工作。当我尝试在模拟器上启动我的应用程序时,它会崩溃,我会看到堆栈跟踪,你可以看到下面的内容:
` Process: com.blackmamba.gopgame, PID: 1873
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.blackmamba.gopgame/com.blackmamba.gopgame.MainMenu}: java.lang.ClassNotFoundException: Didn't find class "com.blackmamba.gopgame.MainMenu" on path: DexPathList[[zip file "/data/app/com.blackmamba.gopgame-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.blackmamba.gopgame.MainMenu" on path: DexPathList[[zip file "/data/app/com.blackmamba.gopgame-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
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:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: com.blackmamba.gopgame.MainMenu
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available`
在这里你可以看到build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
mavenLocal()
}
android {
lintOptions {
abortOnError false
}
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.blackmamba.gopgame"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-v13:22.1.1'
}
和我的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blackmamba.gopgame"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:screenOrientation="portrait">
<activity
android:name="MainMenu"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="HeroSelector"
android:theme="@style/Theme.AppCompat.NoActionBar"/>
</application>
</manifest>
MainMenu代码:
package com.blackmamba.gopgame;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainMenu extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button exitButton = (Button)findViewById(R.id.exit_button);
exitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
Button newGameButton = (Button)findViewById(R.id.new_game_button);
newGameButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainMenu.this, HeroSelector.class);
startActivity(intent);
}
});
}
}
项目树 - &gt; https://www.gv.com/lib/how-to-choose-the-right-ux-metrics-for-your-product
答案 0 :(得分:0)
答案 1 :(得分:0)
Android仍然不支持Java 8,因为android并没有使用它使用一个名为Dalvik的完全独立的虚拟机的java虚拟机,这就是为什么需要花费很长时间和成本来添加很多东西的原因支持java 8,因为它需要从头开始进行更改。