How to create a project in Android Studio without the support library? - android-studio

I'm sorry if this is a stupid question but I'm new to Android development and for my first app, I don't have any plans to support devices running API 17 and lower so I wish to not use the support library. However, when I create a new project in Android Studio (even with no activity) I can still see
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
in my Gradle file.
How can I create a project without the support library? Thanks.

You can remove the support library , removing the dependency from your build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.android.support:appcompat-v7:21.0.3'
}
To set minSdk=17 you can use:
android {
defaultConfig {
minSdkVersion 17
targetSdkVersion 22
}
}

Related

failed to resolve com.android.support.espresso:espresso-core:2.2.2

I've just downloaded android studio for the first time and i'm getting gradle errors. I've downloaded everything the SDK provided and still the same errors.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.noelly.myapplication"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.+'
testCompile 'junit:junit:4.12'
}
The errors I'm getting are
(Failed to resolve: com.android.support.appcompat-v7:25.+)
and
(Failed to resolve: com.android.support.espresso:espresso-core:2.2.2)
Everything by the way is up to date,please help this is really frustrating starting out.
**EDIT FROM ANSWER ONE- PICTURE OF INSTALLED TOOLS---
sdktoolsscreenshot
Code form project build.gradle
// 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.2.3'
// 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
}
New Error messages_____newerrorscreenshot
failed to resolve com.android.support.espresso:espresso-core:2.2.2
This error can occur when we refactor layout name.
I had the same problem and my mistake was that I had created the layout naming test.xml and then when I refactored that name with like layout_offers.xml, my gradle was changed something like
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.detail_layout.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
})
Whereas It should be like follow
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
So, one solution is that we should avoid using test.xml as a layout name.
Here's how your gradle file should look like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.noelly.myapplication"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'
}
Update:
There must be a problem with the SDK you downloaded. Navigate to C:/Users/Noelly/AppData/Local/Android/Sdk/extras/android/m2repository/com/android and delete the support folder.
Now open your SDK Manager and re-install the Android Support Repository.
I got same trouble as yours, and I have found how to solve the problem.
It was because I was using x86 operating system, while android studio was x64.
I went to https://developer.android.com/studio/index.html and pressed 'download option', and installed x86 version of android studio.
Do not uninstall your previous x64 android studio. It is required because of the android sdk.
unpack your x86 android studio anywhere, and find 'bin' folder. There should be your 'studio.exe'.
I got this same error message after renaming a layout file, although everything had just worked before. I fixed this by commenting out these lines from gradle:
androidTestCompile('com.android.support.detail_layout.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
I have no idea why this happened or if this is a good way of fixing it, only hoping that this could be a quick fix for some beginner like me.

Gradle cannot resolve the most recent Firebase libraries , i.e, versions of 9.4.0

I am trying to upgrade my Firebase libraries to the new 9.4.0 version; however, I get the "can't resolve" error in Gradle upon syncing. Here's the error:
Error:(38, 13) Failed to resolve: com.google.firebase:firebase-core:9.4.0
Error:(40, 13) Failed to resolve: com.google.firebase:firebase-auth:9.4.0
Error:(40, 13) Failed to resolve: com.google.firebase:firebase-storage:9.4.0
Tried with and without firebase-core, no difference.
Here's my Gradle for both app and project level:
project level:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and for the module:app level:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.main.projectone"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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.google.android.gms:play-services-gcm:9.2.0'
// compile 'com.google.android.gms:play-services:9.2.1'
compile('com.facebook.android:facebook-android-sdk:4.7.0') {
exclude module: 'bolts-android'
}
// compile 'com.fasterxml.jackson.core:jackson-core:2.8.1'
// compile 'com.fasterxml.jackson.core:jackson-databind:2.8.1'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.android.support:design:24.0.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0#aar'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
}
apply plugin: 'com.google.gms.google-services'
Any idea why Gradle cannot resolve the libraries? Here's Firebase website addressing them Firebase Newest Libs. Appreciate your help.
Update the SDK Tools in Android Studio. After upgrading Google Play Services and Google Repository to the latest versions, I was able to resolve the same issue faced with latest version 9.4.0 of Firebase libraries
I had exactly the same problem and don't understand it, but what fixed it for me:
I went to SDK Manager -> SDK Tools and updated "Google Repository" from rev 31 to rev 32. After that I tried to sync my project again and it magically worked.
In your module:app, try adding
compile 'com.google.android.gms:play-services:9.4.0' instead of compile 'com.google.android.gms:play-services:9.2.1' since, you are using all Firebase libraries of the new 9.4.0 version. Or you can just pick the required new libraries as suggested in Setting Up Google Play Services

How to Include com.questoid.sqlitemanager_1.0.0 jar file in ANDROID STUDIO?? please help on this

How to Include com.questoid.sqlitemanager_1.0.0 jar
file in ANDROID STUDIO?? please help on this
Put it in the folder libs of your app and you have to verify into the builde.gradle the dependecies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Android studio build script error,unsupported gradle DSL method found : android()!

I upgraded the Android Studio to AS 0.6 then imported the project developed in AS 0.3
I am getting errors like:
Build script error,unsupported Gradle DSL method found : android()'!,
Possible causes could be:
- you are using Gradle version where the method is absent
("open_gradle_settings">Fix Gradle settings</a>)
- you didn't apply Gradle plugin which provides the method
(Apply Gradle plugin)
or there is a mistake in a build script (Goto source)
I changed my dependencies path in build.gradle to:
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 14
}
What might the problem?
Is there any guide which tells how to upgrade the project?
Actually it stated in the error message. So just add
apply plugin: 'com.android.application'
between dependencies section and android section
Think of “Gradle DSL method” as a Java method. So in Gradle, methods can be distinguished by either {} or “.”. So
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
is the same as
dependencies.compile fileTree(dir: 'libs', include: ['*.jar'])
where both “dependencies” and “compile” are methods.
So you are including a method somewhere in your build.gradle file that is not supported by your program. For example, make your dependencies this:
dependencies {
nothing 'this.does.nothing.build:gradle:0.7.+'
}
Which is the same as writing:
dependencies.nothing 'this.does.nothing.build:gradle:0.7.+'
And you will see an error saying “unsupported Gradle DSL method found: ‘nothing()’!”
Obviously "nothing" is not a real method. I just made it up.
So one of your "android" methods is wrong.

Unable to resolve Robotium Dependency Android Studio

I am trying to use Robotium for writing test cases in Android Studio and I am having a hard time configuring things.
Following is my build.gradle inside the app.
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
androidTestCompile 'junit:junit:4.11'
}
When I clean the project, I get the following error:
Error:A problem occurred configuring project ':NativeSDK'.
Could not resolve all dependencies for configuration ':NativeSDK:_debugTestCompile'.
Could not find com.jayway.android.robotium:robotium-solo:5.1.
Required by:
InAppSDK:NativeSDK:unspecified
Could not find junit:junit:4.11.
Required by:
InAppSDK:NativeSDK:unspecified
Any help on how to resolve this?
I hope that in your top level build.gradle you have the repositories{mavenCentral()} or repositories{jcenter()} in your buildscript{}
When you provide the reference to an artifact in mavenCentral() or jCenter() you need to sync the project after disabling the offline work at least once under studio>preference>gradle>offline work.
Having this will solve the issue. Its just the local cache of the studio has not been updated as per my understanding. You can check the available library version in mavenCentral() or jcenter() in your case its 5.1 for robotium. (better to use 5.2.1 which is the newest as of today)
make sure that you don't have the robotium jar in your libs folder as you are compiling libs file tree. If you have the jar file when compiling it will throw a UNEXPECTED_TOP_LEVEL exception.

Resources