I recently imported my project from Eclipse to Android Studio and integrated Gradle's projectFlavors to support the different environment (DEV, QA and PROD). Although I encountered a problem with my in app billing. It seems to use the package name to query the google store but depending on my productFlavors the package name changes.
my gradle.build definition
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
Prod {
packageName 'com.test.app'
}
Qa{
packageName 'com.test.app.qa'
versionName '1.2-QA'
}
Dev{
packageName 'com.test.app.dev'
versionName '1.2-DEV'
}
}
}
repositories{
mavenCentral()
mavenLocal()
}
dependencies {
compile 'com.test.android:infra:1.0#aar'
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:4.3.23#aar'
compile files('libs/adgear-android-sdk.jar')
compile files('libs/crashlytics.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile project(':libraries:facebook')
}
Thanks for your time.
You gotta change the packageName property to applicationId.
productFlavors {
Prod {
applicationId 'com.test.app'
}
Qa{
applicationId 'com.test.app.qa'
versionName '1.2-QA'
}
Dev{
applicationId 'com.test.app.dev'
versionName '1.2-DEV'
}
}
Related
I am trying to enable Samsung Pay within My Braintree Sandbox Payment Gateway. I update my processing settings in my Braintree sandbox dashboard and As Per This Link update my module-level build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.android.testparseapplication"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// BRAINTREE API
implementation 'com.braintreepayments.api:drop-in:3.6.0'
// Samsung Pay -- Api >= 23
implementation 'com.braintreepayments.api:braintree:2.16.0'
implementation 'com.braintreepayments.api:samsung-pay:1.0.0'
// Samsung JAR to libs folder of project
implementation(group: 'com.samsung.android', name: 'samsungpay', version: '1.9.0', ext: 'jar') <---- PRODUCES ERROR
}
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
flatDir {
dirs "${rootDir}/libs"
}
}
apply plugin: 'com.google.gms.google-services'
However End With The Error: Failed to resolve: com.samsung.android:samsungpay:1.9.0
Any recommendations ?
I created 2 flavors (com.example.admin.deb) and (com.example.admin.lab_127) And the difference between this two packages is in the MainActivity.java file (just two lines of code). In the build.gradle I created
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.admin.deb"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors{
pro {
applicationId "com.example.admin.lab_127"
}
deb {
applicationId "com.example.admin.deb"
dependencies {
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'org.lucasr.dspec:dspec:0.1.1'
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.+'
}
But when I change Build Variant nothing happens.My folder structure like this:
-app
----manifests
------------AndroidManifest.xml
----java
--------com.example.admin.deb
-----------MainActivity.java
--------com.example.admin.lab_127
-----------data
-----------ItemAdapter.java
-----------MainActivity.java
----res
So what I did wrong? Thanks in advance.
If you want to have a different version of the same class in the two flavor you'll need to create it in both flavors and do not put it in src/main/java. In your case:
src/deb/java/com/example/admin/deb/MainActivity.java
src/pro/java/com/example/admin/deb/MainActivity.java
You should implement next structure:
app
src
deb
java
com.example.admin.deb
MainActivity.java
main
java
com.example.admin.deb
res
pro
java
com.example.admin.deb
MainActivity.java
Anyone know what I'm missing? My program worked 5 minutes ago and know I have this strange error:
17:16:38 UnsupportedMethodException
Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.: Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I can't ignore it because I can not run it anymore on my android device, anyone?
Build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:appcompat-v7:21.+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
As I thought, there are many out of date plugins/tools here. Please try this fixed and updated build.gradle:
Also, make sure you are using the latest build plugin: com.android.tools.build:gradle:1.1.3.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 // <-- was 21
buildToolsVersion "22.0.1" // <-- was 20.0.0
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 22 // <-- was 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:6.5.87' // <-- was 4.2.42
compile 'com.android.support:appcompat-v7:22.0.0' // <-- was 21.+
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1' // (the only up to date plugin you had)
}
I am running into the zero supported device issue when publishing an Android application. I upload an APK, and Google Play tells me there is zero supported device.
My manifest is pretty simple, the only thing apart from the <application> section is this:
<uses-permission android:name="android.permission.INTERNET" />
I have no file in app/libs. I am using Android Studio.
The build.gradle file looks like this:
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.the.application"
minSdkVersion 15
targetSdkVersion 20
versionCode 902
versionName "0.9.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
production {
packageName "com.the.application"
}
test {
packageName "com.the.application.test"
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.zxing:core:3.0.0'
compile 'com.google.zxing:android-integration:3.1.0'
}
Any clue what could cause that?
I am trying to learn android in android studio.Now i imported an eclipse project in android studio and now while trying to run it it is not building.Some problems in gradle may be..
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.practise"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:gridlayout-v7:+'
}
Can anyone help me to find out the problem??
Change your dependencies
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
}
Using the +, you are getting the last release.
Currently the last release is the compile 'com.android.support:support-v4:21 and it has a minSdk='L' because it is a preview release.
Use it only to test the android 'L' preview.
Try editing the following line to your Android Manifest file, like so:
dependencies {
compile 'com.android.support:support-v4:21+'
}
Then your project should build.
Change your dependencies in app/build.gradle to lower version
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.eusecom.snowsmsden"
minSdkVersion 16
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'com.android.support:appcompat-v7:20.+'
}