Android Studio Build APK没有报错,但是Generate signed apk报错

有时候 ,我们在调试APK,直接Build是可以正常生成,没有报错,但是当我们将自己的签名文件加上去,就会报错。一般情况下,我们可以在build.gradle中的android{}里面添加一个东西

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

  整个文件如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "com.zhongxuan.himclient"
        minSdkVersion 11
        targetSdkVersion 17
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    compile files('libs/zxing.jar')
    compile files('libs/gson-2.6.1.jar')
    compile files('libs/xUtils-2.6.14.jar')
}

 参考链接:http://dditblog.com/itshare_657.html

还有一种错误

Error: Expected resource of type styleable [ResourceType] 
这个错误在编译运行时候并不会出现,但是当需要编译打包的时候,就会爆出这个异常。

这种错误,只需要在提示错误的类里面加入这句:

@SuppressWarnings("ResourceType")

例如:

@SuppressWarnings("ResourceType")
public void initView() {
    TypedArray ta = mContext.obtainStyledAttributes(attrs);
    boolean hasBottomLine = ta.getBoolean(0, false);
    boolean hasTopLine = ta.getBoolean(1, false);
    ta.recycle();
}

参考链接:http://blog.csdn.net/zhufuing/article/details/50901133

原文地址:https://www.cnblogs.com/linfenghp/p/7730444.html