我在构建可调试的apk时遇到了麻烦。我正在使用Android Studio 0.5.4 / 0.5.5和Gradle 1.11 Gradle插件0.9。+以某种方式调试apk不再显示包名称的任何logcat消息。我尝试了许多不同的东西卸载所有Android studio / AndroidSDK。并再次清理安装它,还删除了所有主文件夹.gradle .androidstudiopreview并没有任何帮助。当我在android studio中创建一个新项目并按照向导创建活动时,一切似乎都很好,应用程序是可调试的,并在logcat中显示正常的日志记录输出。此外,当我想选择调试过程时,Android Studio无法将其视为可调试过程。任何人都知道如何解决这个或我的build.gradle文件中的错误
日志消息的输出现在是这样的:
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.+'
}