enter code hereunable to fix the project , new to android studio , need help fixing gradle my gradle file ,happening when i import projects from eclipse, exporting done fine
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':ksoap2-android-assembly-2.5.8-jar-with-dependencies')
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
and the error i am getting is
Error:Configuration with name 'default' not found.
changed code
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.package.name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':ksoap2-android-assembly-2.5.8-jar-with-dependencies')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.package.name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Add the defaultConfig into the android block
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.package.name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
EDIT 1 : The android part of your gradle file should be inside the applications build.gradle not in the projects root gradle
There are two gradle files
Here is a sample Root Project Gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Sample Module Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.package.name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:cardview-v7:23.1.1'
}
Related
my project has an error when running is :
error: cannot find symbol variable AudioSystem
I have made sure that my code had imported :
import android.media.AudioSystem;
and the SDK version 19 has been installed
, and my build.Gradle information as below:
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
How do I overcome this error? Thanks
When I typed the letter "A" after "import android.media.",the Auto list didn't show AudioSystem to let me to select.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
tasks.withType(JavaCompile) { options.encoding = "UTF-8" }
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile files('3rd_party_library/dom4j-1.6.1.jar')
compile files('3rd_party_library/jaxen-1.1-beta-7.jar')
compile files('3rd_party_library/core-3.2.1.jar')
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.test.smmitest"
minSdkVersion 19
targetSdkVersion 23
versionCode 20170713
versionName "4.5.6"
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
signingConfigs {
release {
}
debug {
storeFile file("Keystore/debug.keystore");
storePassword ("android");
keyAlias = "androiddebugkey";
keyPassword = "android";
}
}
buildTypes {
release {
}
debug {
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
When Android studio does Gradle sync, it has the following error message:
Gradle "MyApplication2" project refresh failed
Error:Cause: com.android.build.gradle.managed.ProductFlavor$Impl
After searching, still cannot get rid of it. Could you help? Thanks!
My project build.grade:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My module build.gradle:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "SamplePlayer"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
ndk {
moduleName "SamplePlayer"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
jni.srcDirs = []
}
}
task ndkBuild(type: Exec) {
commandLine 'ndk-build', '-C', file('src/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
android.lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-android.txt'))
}
}
}
dependencies {
compile fileTree(dir: '../Jar', include: '*.jar')
compile fileTree(dir: 'libs', include: '*.jar')
}
My other module build.gradle:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "com.example.cfcalex.myapplication2"
minSdkVersion.apiLevel = 22
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-android.txt'))
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
please help me , i got bellow error.
I am try to integrate "onyxenrollwizardsampleapp" Sample app in my Project as a module, but getting below error.
//Module app:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android{
compileSdkVersion 19
buildToolsVersion "22.0.1"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
compileOptions {
}
}
repositories{
mavenCentral()
maven {
url 'http://nexus.diamondfortress.com/nexus/content/repositories/releases'
}
maven {
url 'http://nexus.diamondfortress.com/nexus/content/repositories/snapshots'
}
}
dependencies{
compile 'com.dft.android:onyx-enroll-wizard:4.1.3'
}
**//project app:
build.grade:**
epositories{
mavenCentral()
}
apply plugin: 'com.android.application'
buildscript{
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
dependencies{
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':onyxenrollwizardsampleapp')
}
android{
compileSdkVersion 19
buildToolsVersion "22.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
allprojects {
repositories {
jcenter()
}
}
Getting Error:
Error:Failed to resolve: com.dft.android:onyx-enroll-wizard:4.1.3
At first modify your build.gradle
You can use apply plugin: 'com.android.application' instead of apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "" // Set Yours
minSdkVersion 14
targetSdkVersion 22
}
Finally
apply plugin: 'com.android.application'
android{
compileSdkVersion 22
buildToolsVersion "22.0.1"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
compileOptions {
}
}
repositories{
mavenCentral()
maven {
url 'http://nexus.diamondfortress.com/nexus/content/repositories/releases'
}
maven {
url 'http://nexus.diamondfortress.com/nexus/content/repositories/snapshots'
}
}
dependencies{
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.dft.android:onyx-enroll-wizard:4.1.3'
}
Then Build menu - Clear Project and Rebuild Project .
I am not sure how to get my project to build Card.IO with Gradle. My gradle file looks as follows:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "applicationId"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
My local.properties are as follows:
sdk.dir=/Applications/Android Studio.app/sdk
ndk.dir=/Applications/Android Studio.app/android-ndk-r10b
And my Project structure is as follows:
Now according to Card.IO (https://github.com/card-io/card.io-Android-SDK) all I need to do is copy the files into the correct directory, but this is not working.
I have also looked at the following posts:
Card.IO on Android with Gradle
https://github.com/paypal/PayPal-Android-SDK/issues/26 - this suggests some extra gradle methods but does no work
When I do this to my Gradle file:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "appId"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
java.srcDirs = ['src/main/java', 'src-gen/main/java']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
productFlavors {
x86 {
versionCode Integer.parseInt("6" + defaultConfig.versionCode)
ndk {
abiFilter "x86"
}
}
mips {
versionCode Integer.parseInt("4" + defaultConfig.versionCode)
ndk {
abiFilter "mips"
}
}
armv7 {
versionCode Integer.parseInt("2" + defaultConfig.versionCode)
ndk {
abiFilter "armeabi-v7a"
}
}
arm {
versionCode Integer.parseInt("1" + defaultConfig.versionCode)
ndk {
abiFilter "armeabi"
}
}
fat
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
Then Card.IO works, but I get the error: Crashlytics couldn't find the res folder specified in sourceSets.main.res, please make one. It picked: src/main/res.
I am very sure my problem is just a misunderstanding on Gradle - I am new to it. But there are no up to date complete answers that I can look at.
Somewhere along the line I managed to delete my Res folder using some gradle settings. Now when I put the gradle file back and the res files back it all compiles fine. Weird.
Thank goodness for Android Studio's view local history or I would have been set back a couple of days!
Not able to solve this error, I have updated Android studio. gone throungh other this solutions but not worked for me, please help..
Build script error, unsupported Gradle DSL method found: 'release()'!
Possible causes could be:
- you are using Gradle version where the method is absent
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
Gradle settings
Gradle version - 0.9
Main gradle.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
}
Project Gradle file
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion '18.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
signingConfigs {
release {
storeFile file('dsc.jks')
storePassword 'dscneo'
keyAlias 'dsc'
keyPassword 'dscneo'
}
}
buildTypes {
debug {
versionNameSuffix '-DEBUG'
}
beta {
versionNameSuffix '-BETA'
}
release {
signingConfig signingConfigs.release
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.android.support:support-v4:+'
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/gson-2.1.jar')
compile project(':facebook')
compile project(':TabIndicatorLibrary')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile project(':VerticalViewPager')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/universal-image-loader-1.9.1-sources.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/HockeySDK-3.0.1.jar')
}
Facebook SDK gradle file
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Other library project gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
android {
compileSdkVersion 16
buildToolsVersion '18.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
one more library project gradle file.
apply plugin: 'android-library'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
In your last file (library) you have the release block inside the android block.
The DSL for the library projects is now the same as for the application projects
In particolar you have to put the release block inside the buildTypes.
android {
buildTypes {
release {
}
}
Also I suggest you use buildToolsVersion '19.0.x' for all your gradle files.
You can put it in your build.gradle in root folder.
ext {
compileSdkVersion = 19
buildToolsVersion = "19.0.3"
}
Then in each build.gradle file you can use:
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion