我已经下载了android studio 2.2.1,但我无法在较低的API版本上运行我的项目,它在棒棒糖和marshmallow上运行。我的模块.gradle内容如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
defaultConfig {
applicationId "com.example.admin.autoworld"
minSdkVersion 15
targetSdkVersion 24
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(include: ['*.jar'], dir: 'libs')
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:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
compile 'com.android.support:multidex:1.0.1'
}
这是日志猫......它在启动画面中显示一些错误
FATAL EXCEPTION: main
Process: com.example.admin.autoworld, PID: 4574
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.admin.autoworld/com.example.admin.autoworld.SplashScreen}: android.view.InflateException: Binary XML file line #27: Error inflating class android.widget.ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500)
at android.app.ActivityThread.access$900(ActivityThread.java:171)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5679)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.widget.ImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
at android.app.Activity.setContentView(Activity.java:2059)
at com.example.admin.autoworld.SplashScreen.onCreate(SplashScreen.java:18)
这是启动画面的xml文件
答案 0 :(得分:0)
由于你的问题不清楚,我只想给你一个答案。
当您从棒棒糖或marshmallow构建应用程序并尝试在较低版本中编译时,可能会发生应用程序兼容性,而不会注意到您已在材料设计中编写它。
如果您想在kitkat或更低版本上运行
,最好尝试更改设计问题http://android-developers.blogspot.com/2015/05/android-design-support-library.html
我也在kitkat中遇到过它,需要将设计改为appcompatactivity(在xamarin C#中)以支持我用过的材料设计:)
注意::您不需要逐字更改,只需更改编码以支持较低版本的材料设计。您可以在较低版本上使用材料设计,但您必须支持它
答案 1 :(得分:0)
我尝试了很多并且最终找到了答案......因为我使用的是材料设计它不支持爱人api ...我已经删除了自定义工具栏并从头开始重新创建项目