Reputation: 4866
I wrote a little Hello World
program using Android Studio
. Minimal sdk API is 16. I installed the virtual device running on API 21 and the program works fine. I also tried to run the program on a Galaxy S5 with Android 6 Cell phone which works fine.
I then connected my phone (Galaxy S2 with Jelly Bean) and tried to run it on the phone. However it only closed the app and displayed program closed.
Here is the log shown by Android Studio
And this is the Module:app build.gradle file:
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'
}
The entire project directory can be found here.Any help on were I go wrong would be greatly appreciated.
Edit: I forgot to mention I'm using Android Studio 2.2 Prev 5 on Ubuntu 14.4
Upvotes: 0
Views: 2158
Reputation: 18725
All the information is available in your log, please review it closely, and will discover your issue (related to Vector Drawable). All the information is called out in the log (including line numbers, etc), so just follow the errors, which explain the issue you have.
Start at the bottom of your log and move up. You will see that you have an issue with the Vector Drawables you are including, based on this message:
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
Then if you move further up the stack, you will find other interesting tidbits, including:
E/VdcInflateDelegate: Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
at
Upvotes: 0
Reputation: 6010
If you are using v1.5.0 or below of the Gradle plugin, you need the following code in your app’s build.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
Upvotes: 1