Android 构建调试APK
我在构建可调试的apk时遇到问题。我使用的是Android Studio 0.5.4/0.5.5和Gradle 1.11 Gradle plugin 0.9.+并且调试apk不再显示任何带有包名的logcat消息。我尝试了很多不同的方法卸载Android studio/AndroidSDK中的所有内容。再次安装时,也删除了所有主文件夹.gradle.androidstudiopreview,但没有任何帮助。当我在androidstudio中创建一个新项目并按照向导创建一个活动时,一切看起来都很好,该应用程序是可调试的,并在logcat中显示正常的日志输出。另外,当我想选择要调试的进程时,Android Studio无法将其作为可调试进程。有人知道如何修复此问题,或者知道我的build.gradle文件中的错误吗 日志消息的输出如下所示:Android 构建调试APK,android,gradle,android-studio,android-gradle-plugin,build.gradle,Android,Gradle,Android Studio,Android Gradle Plugin,Build.gradle,我在构建可调试的apk时遇到问题。我使用的是Android Studio 0.5.4/0.5.5和Gradle 1.11 Gradle plugin 0.9.+并且调试apk不再显示任何带有包名的logcat消息。我尝试了很多不同的方法卸载Android studio/AndroidSDK中的所有内容。再次安装时,也删除了所有主文件夹.gradle.androidstudiopreview,但没有任何帮助。当我在androidstudio中创建一个新项目并按照向导创建一个活动时,一切看起来都很好
04-15 14:09:11.066 21202-21202/? D/Tag﹕ test tag and debug messages
04-15 14:09:11.066 21202-21202/? I/Tag﹕ test tag and info messages
04-15 14:09:11.066 21202-21202/? W/Tag﹕ test tag and warn messages
04-15 14:09:11.066 21202-21202/? E/Tag﹕ test tag and error messages
04-15 14:09:11.076 21202-21202/? D/Tag﹕ is debuggable: true
build.gradle:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
def gitSha() {
return 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
}
def buildTime() {
return new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
}
def isTravis = "true".equals(System.getenv("TRAVIS"))
def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
android {
final GITSHA = "${gitSha()}";
final BUILD_TIME = "${buildTime()}";
final YOUTUBE_DEV_API = "AIzaSyD0kNRnV_Il6bYx5ekWUzPWNt9XDQIPxvg"
compileSdkVersion 19
buildToolsVersion '19.0.3'
dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !isTravis
}
defaultConfig {
packageName "com.test"
minSdkVersion 9
targetSdkVersion 19
versionCode Integer.parseInt(VERSION_CODE)
versionName VERSION_NAME
buildConfigField "String", "GIT_SHA", "\"${GITSHA}\""
buildConfigField "String", "BUILD_TIME", "\"${BUILD_TIME}\""
testPackageName "com.whosampled.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testFunctionalTest true
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile file("../test.keystore")
storePassword "#2U3aD+2ASwayEwa"
keyAlias "debug"
keyPassword "gu*W5cUkUM-&5bre"
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
zipAlign true
buildConfigField "String", "YOUTUBE_API", "\"${YOUTUBE_DEV_API}\""
}
debug {
signingConfig signingConfigs.debug
debuggable true
jniDebugBuild true
runProguard false
zipAlign false
packageNameSuffix ".debug"
versionNameSuffix "-" + GITSHA + "-debug"
buildConfigField "String", "YOUTUBE_API", "\"${YOUTUBE_DEV_API}\""
}
android.applicationVariants.all { variant ->
println "*********" + variant.getVariantData().getVariantConfiguration().getBuildType().isDebuggable() + "**********";
}
if (false) {
// change apk off build variant.
android.applicationVariants.all { variant ->
println "*********" + variant.description + "**********";
def variants = variant.baseName.split("-");
variant.buildType
def apkName = "whosampled-";
apkName += variants[0];
apkName += "-v" + android.defaultConfig.versionName;
apkName += "-" + GITSHA;
if (!variant.zipAlign) {
apkName += "-unaligned";
}
// if created by build server or something
if (false && variant.buildType.name == "release") {
apkName += "-RELEASE.apk";
} else if (false && variant.buildType.name == "debug") {
apkName += "-SNAPSHOT.apk";
} else {
apkName += ".apk";
}
println "*********" + "$project.buildDir/apk/" + apkName + "**********";
variant.outputFile = file("$project.buildDir/apk/" + apkName)
}
}
}
}
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/groups/public/' }
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.squareup.retrofit:retrofit:1.5.0'
compile 'com.squareup.picasso:picasso:2.2.0'
compile 'com.squareup.okhttp:okhttp:1.5.3'
compile 'com.pixplicity.easyprefs:library:1.0@aar'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'se.emilsjolander:stickylistheaders:2.3.0'
compile 'com.squareup:otto:1.3.4'
compile 'com.pixplicity:font.text.utils.library:1.2@aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.squareup:fest-android:1.0.+'
}
我不认为这和Gradle有任何关系。日志输出显示一个pid,ddms给出一个pid->app包映射,因此日志的显示是studio使用映射来显示app包的。那么是什么原因造成的呢?它工作正常,一下子我就无法调试了,我不知道我做错了什么。