首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我的项目文件不包括在apk中。

我的项目文件不包括在apk中。
EN

Stack Overflow用户
提问于 2015-07-30 11:40:31
回答 2查看 147关注 0票数 2

我总是得到java.lang.ClassNotFoundException: ru.ooolpi.lpiapp.ui.activity.MainActivity。但我有这样的课。后来我发现我的项目文件在apk中丢失了。

我的构建脚本:

代码语言:javascript
运行
复制
buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        //  classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.1'
        //classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
    }
}
//apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

repositories {
    maven { url 'https://github.com/donnfelker/mvn-repo/raw/master/' }
    maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
    jcenter()
}

dependencies {
    compile 'com.android.support:multidex:1.0.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.squareup.dagger:dagger:1.2.2'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup:otto:1.3.8'
    apt 'com.squareup.dagger:dagger-compiler:1.0.1'
}

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        //applicationId "ru.ooolpi.lpiapp"
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 2
        versionName "1.0.1"
        multiDexEnabled true
    }
    packagingOptions {
        // Exclude file to avoid
        // Error: Duplicate files during packaging of APK
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude '.readme'
    }
    dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g"
    }
    signingConfigs {
        release {
            storeFile file('../devcert.jks')
            storePassword '123456'
            keyAlias 'dev'
            keyPassword '123456'
        }
    }
    lintOptions {
        //disable 'InvalidPackage'
        abortOnError false
    }
    compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            zipAlignEnabled true // this is default for release
        }
        debug {
            applicationIdSuffix '.debug'
            minifyEnabled false
        }
    }
}

我试着用Android和gradlew构建。结果是相同的-我的文件不包括在apk中。

更新:我的项目结构

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-05 16:02:43

问题是我对匕首和它的编译器使用了不同的版本。

情况如何:

代码语言:javascript
运行
复制
compile 'com.squareup.dagger:dagger:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.0.1'

看起来应该是:

代码语言:javascript
运行
复制
compile 'com.squareup.dagger:dagger:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.2.2'

因此,Android拒绝突出我的代码中的问题(我不知道为什么这些问题是相关的)。

票数 0
EN

Stack Overflow用户

发布于 2015-07-30 12:54:12

看看你的配置文件。

确保你没有删除你在你的应用程序中使用的任何类。要手动保存这些类,请添加以下行:

代码语言:javascript
运行
复制
-keep class ru.ooolpi.lpiapp.** { *; }
-dontwarn ru.ooolpi.lpiapp.**
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31722799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档