我最近开始修补Jenkins和android。我在自己的服务器上安装了jenkins,还安装了graddle和android sdk。 请在下面找到我的配置:
我得到生成的.apk文件列表,但是在我的设备上安装debug-app.apk时崩溃时出现以下错误:
07-24 19:18:34.043 26394-26394/bikeparts.triplustutorials.be.bikeparts E/AndroidRuntime: FATAL EXCEPTION: main
Process: bikeparts.triplustutorials.be.bikeparts, PID: 26394
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{bikeparts.triplustutorials.be.bikeparts/bikeparts.triplustutorials.be.bikeparts.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "bikeparts.triplustutorials.be.bikeparts.LoginActivity" on path: DexPathList[[zip file "/data/app/bikeparts.triplustutorials.be.bikeparts-2/base.apk"],nativeLibraryDirectories=[/data/app/bikeparts.triplustutorials.be.bikeparts-2/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "bikeparts.triplustutorials.be.bikeparts.LoginActivity" on path: DexPathList[[zip file "/data/app/bikeparts.triplustutorials.be.bikeparts-2/base.apk"],nativeLibraryDirectories=[/data/app/bikeparts.triplustutorials.be.bikeparts-2/lib/arm64, /system/lib64, /vendor/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:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
任何可能出错的线索?
Gradle文件(默认生成):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "bikeparts.triplustutorials.be.bikeparts"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
}
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bikeparts.triplustutorials.be.bikeparts">
<uses-permission android:name="android.permission.INTERNET" />
<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=".LoginActivity"
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>
答案 0 :(得分:0)
我自己解决了这个问题。我使用了graddle命令“assemble”而不是“build”。接下来,我确保将jdk添加到jenkins。
我通过在项目的工作区中手动测试并执行“gradlew assemble”来解决所有问题。