And*_*ons 6 sdk android build-tools android-gradle-plugin
我面临的问题是我的Android应用程序在具有API 5.0及更高版本的设备上运行良好但在具有Kitkat(4.4)及其相应的较低版本的设备上崩溃.我知道它与我的gradle文件中的构建工具有某种关系,但是仍然无法弄清楚问题.有人可以帮我解决这个问题.
这是我的gradle文件,
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'android'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.abc.example"
minSdkVersion 10
targetSdkVersion 22
multiDexEnabled true
versionCode 12
versionName "1.0"
}
buildTypes {
release {
multiDexEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android {
packagingOptions {
exclude 'META-INF/LICENSE'
}
}
android {
packagingOptions {
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
transitive = true
exclude module: 'httpclient'
exclude group: 'httpclient'
}
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:mockwebserver:2.3.0'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile files('libs/bitlyj-2.0.0.jar')
}
Run Code Online (Sandbox Code Playgroud)
在构建项目时也会出现此错误,
Caused by: java.lang.NoClassDefFoundError: com.package.R$styleable
at com.package.widgets.StyleableTextView.<init>(StyleableTextView.java:23)
Run Code Online (Sandbox Code Playgroud)
这是StyleableTextView类,
public class StyleableTextView extends TextView {
public StyleableTextView(Context context) {
super(context);
}
public StyleableTextView(Context context, AttributeSet attrs) {
super(context.getApplicationContext(), attrs);
UiUtil.setCustomFont(StyleableTextView.this, context, attrs,
R.styleable.com_eywa_wonk_widgets_StyleableTextView,
R.styleable.com_eywa_wonk_widgets_StyleableTextView_font);
}
public StyleableTextView(Context context, AttributeSet attrs, int defStyle) {
super(context.getApplicationContext(), attrs, defStyle);
UiUtil.setCustomFont(StyleableTextView.this, context, attrs,
R.styleable.com_eywa_wonk_widgets_StyleableTextView,
R.styleable.com_eywa_wonk_widgets_StyleableTextView_font);
}
}
Run Code Online (Sandbox Code Playgroud)
这是attrs的风格,
<resources>
<attr name="font" format="string" />
<declare-styleable name="com.package.widgets.StyleableTextView">
<attr name="font" />
</declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)
小智 27
当你使用时multidex,然后尝试扩展你的应用程序类,MultiDexAppication而不是Application覆盖以下方法,这需要Android 5.0以下(因为5.0及以上支持multidex)
@Override
protected void attachBaseContext(Context base)
{
super.attachBaseContext(base);
MultiDex.install(BaseApplication.this);
}
Run Code Online (Sandbox Code Playgroud)
并在依赖项中添加此
编译'com.android.support:multidex:1.0.1'
| 归档时间: |
|
| 查看次数: |
11952 次 |
| 最近记录: |