设置Android Studio for果冻豆
我用Android Studio
写了一个Hello World
程序。最小sdk API是16.我安装了运行在API 21上的虚拟设备,程序工作正常。我也尝试在运行Android 6手机的Galaxy S5上运行该程序,该程序运行良好。设置Android Studio for果冻豆
然后我连接我的手机(Galaxy S2与果冻豆),并试图在手机上运行它。但它只关闭应用程序并显示程序关闭。
Here is the log shown by Android Studio
这是模块:应用的build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "magu.schwaderina"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
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:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:support-vector-drawable:24.0.0'
testCompile 'junit:junit:4.12'
}
整个项目目录可以发现here。任何帮助的人,我去错了,将不胜感激。
编辑:我忘了提我使用的Android Studio 2.2中一个5在Ubuntu 14.4
如果您正在使用V1.5.0或低于摇篮插件,你需要在你的应用程序的构建下面的代码。 gradle这个:
android {
defaultConfig {
// Stops the Gradle plugin’s automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88#.njl8u0f91
感谢您的回答。我使用的是Gradle版本2.1,它会自动在链接中添加'vectorDrawables.useSupportLibrary = true'这一行,这是一个很好的读取。 –
所有的信息在你的日志中找到,请仔细阅读它,会发现您的问题(与矢量可绘制)。所有的信息都会在日志中记录下来(包括行号等),所以只需按照错误来解释您所遇到的问题即可。
从日志底部开始向上移动。你会看到,你有你的包括矢量绘图资源的问题,在此基础上的消息:
java.lang.RuntimeException: Unable to start activity ComponentInfo{magu.schwaderina/magu.schwaderina.Main}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
然后,如果你进一步向上移动堆栈,你会发现其他有趣的花絮,包括:
E/VdcInflateDelegate: Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
at
虽然信息在那里,但我仍然无法采取行动。你能详细解释一下吗? –
Android studio已经为每个api版本设置了,没有什么像**设置Android Studio for Jelly Bean ** .. !! –
你可以发布你的android studio –
@APPBird的错误日志。错误日志链接以及整个项目,我不能直接将它们粘贴到问题中,因为它们太长。 –