2014-08-30 15 views
5

Tôi vừa cập nhật Android Studio từ 0,6 lên 0,8,6 và có vẻ như khả năng chỉ định cấu hình "chạy" mặc định đã bị xóa (hoặc chuyển sang vị trí tôi cần giúp tìm). Tôi có thể tạo APK đã ký bằng chế độ gỡ lỗi hoặc chế độ phát hành (thuật sĩ tạo đã được thay đổi để cho phép tôi chọn biến thể xây dựng tại thời điểm này) nhưng dường như không thể tìm hiểu cách chọn biến thể xây dựng cho chung sử dụng. Nói cách khác, khi tôi nhấp vào "chạy" gradle thực hiện assembleRelease khi tôi cần phải chạy assembleDebug. Bất kỳ ý tưởng làm thế nào để thay đổi điều này?Android Studio 0.8.6 thay đổi biến thể xây dựng mặc định

EDIT: Khi tôi chọn "gỡ rối" thay vì "chạy" gradle vẫn chọn để chạy assembleRelease, vì vậy tôi nhận được lỗi này

Cannot debug application com.caseybrooks.scripturememory on device lge-vs985_4g-VS9854Gc824b3f1. 
This application does not have the debuggable attribute enabled in its manifest. 
If you have manually set it in the manifest, then remove it and let the IDE automatically assign it. 
If you are using Gradle, make sure that your current variant is debuggable. 

Tuy nhiên, nếu tôi thêm các thuộc tính debuggable="true" để biểu hiện của tôi, xây dựng không thành công. Build.gradle của tôi có đúng không?

apply plugin: 'android' 

android { 
compileSdkVersion 19 
buildToolsVersion '19.1.0' 
defaultConfig { 
    minSdkVersion 8 
    targetSdkVersion 19 
} 
signingConfigs { 
    release { 
     storeFile file('C:/Users/Casey/Documents/android/scripturememory/scripturememory_keystore') 
     keyAlias 'scripturememory_keystore' 
     storePassword '***********' 
     keyPassword '**********' 
    } 
} 
buildTypes { 
    release { 
     runProguard false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     signingConfig signingConfigs.release 
    } 
} 
productFlavors { 
} 
sourceSets { 
    main { 
     java.srcDirs = ['src/main/java'] 
    } 
} 
} 

dependencies { 
compile project(':library') 
compile project(':AndroidBibleTools') 
compile 'com.android.support:appcompat-v7:19.+' 
} 
+0

Đây có phải là [menu tùy chọn xây dựng] (http://prntscr.com/4i1h6j) mà bạn đang tìm kiếm không? – Zyerah

+0

Không, tôi không thấy bất kỳ tùy chọn nào để thay đổi biến thể xây dựng trong menu đó. – cjbrooks12

Trả lời

15

Trình đơn xem> Công cụ Windows> Chế độ xem Biến thể cho phép bạn chọn kiểu/kiểu xây dựng mặc định cho các mô-đun trong dự án của bạn.

+0

Đây chính xác là những gì tôi đang tìm kiếm, cảm ơn bạn! – cjbrooks12

10

Hãy thử sử dụng tính năng này cho tệp xây dựng gradle của bạn. Tôi thường đặt cờ có thể gỡ lỗi trong tệp gradle chứ không phải tệp kê khai.

buildscript { 
     repositories { 
      mavenCentral() 
     } 
     dependencies { 
      classpath 'com.android.tools.build:gradle:0.12.2' 
     } 
    } 

    apply plugin: 'com.android.application' 

    repositories { 
     mavenCentral() 
    } 

    android { 
    compileSdkVersion 19 
    buildToolsVersion '19.1.0' 
    defaultConfig { 
     minSdkVersion 8 
     targetSdkVersion 19 
    } 
    packagingOptions { 
      exclude 'META-INF/DEPENDENCIES' 
      exclude 'META-INF/LICENSE' 
      exclude 'META-INF/NOTICE' 
      exclude 'META-INF/ASL2.0' 
     } 
    signingConfigs { 
     release { 
      storeFile file('C:/Users/Casey/Documents/android/scripturememory/scripturememory_keystore') 
      keyAlias 'scripturememory_keystore' 
      storePassword '***********' 
      keyPassword '**********' 
     } 
    } 
     buildTypes { 
      debug { 
       applicationIdSuffix '.dev' 
       debuggable true 
       jniDebugBuild true 
       runProguard false 
      } 
      beta { 
       applicationIdSuffix '.beta' 
       debuggable true 
       jniDebugBuild true 
       runProguard false 
      } 
      release { 
       debuggable false 
       jniDebugBuild false 
       runProguard false 
       signingConfig signingConfigs.release 
      } 
     } 
    sourceSets { 
     main { 
      java.srcDirs = ['src/main/java'] 
     } 
    } 
    } 

    dependencies { 
    compile project(':library') 
    compile project(':AndroidBibleTools') 
    compile 'com.android.support:appcompat-v7:19.+' 
    } 
+1

Điều này làm việc tuyệt vời cho tôi. Tôi đã có một hương vị sản phẩm khác được gọi là 'dev' (vì nhiều lý do khác) và thiết lập giá trị gỡ lỗi trong hương vị làm việc tuyệt vời. Cảm ơn! –

+0

Cảm ơn. Đây là những gì tôi đã tìm kiếm. Nếu bạn muốn gỡ lỗi phiên bản phát hành, bạn nên viết 'debuggable true' trong nhánh 'release' cho đến khi bạn thực sự tạo APK đã ký, nơi bạn nên tránh thông tin gỡ lỗi. – CoolMind

Các vấn đề liên quan