how can i download AppCompatActivity librery for ADT - java

I have a problem with importing the package :
"import android.support.v7.app.AppCompatActivity".. i think because i should
download AppCompatActivity librery before importing it
Please, how can i download AppCompatActivity librery??
[1]: https://i.stack.imgur.com/mMPQs.png

No need to download it separately.You can fix it updating your "build.gradle(Module:app)" file. in order to do it you need to add your compiler dependencies for project.
Add this line to "build.gradle(Module:app)" file
compile 'com.android.support:appcompat-v7:25.3.0'
then Sync your project and make sure network connection is working.That's it :)
bellow is an example that shows where you add a compiler dependency to your project.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espressocore:2.2.2',{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.0'
testCompile 'junit:junit:4.12'
}

To Setup Android Support Library :
The Android Support Repository package is provided as a supplemental download to the Android SDK and is available through the Android SDK Manager.
Follow the instructions below to obtain the Support Library files.
To download the Support Library through the SDK Manager:
1.Start the Android SDK Manager.
2.In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder and, if necessary, expand to show its contents.
3.Select the Android Support Repository item.
4.Click the Install packages... button.
Then After Downloading,
Adding Support Libraries
In order to use a Support Library, you must modify your application's project's classpath dependencies within your development environment. You must perform this procedure for each Support Library you want to use.
To add a Support Library to your application project:
Make sure you have downloaded the Android Support Repository using the SDK Manager.
Open the build.gradle file for your application.
Add the support library to the dependencies section. For example, to add the v4 core-utils library, add the following lines:
dependencies {
...
compile "com.android.support:support-core-utils:25.3.1"
}
Then you can use your Support Library elements.

Related

Android Studio 3.X update and lost connection with AChartEngine (can't find symbol class ChartFactory)

I'm using AChartEngine in my project and connected it in build.gradle via
allprojects {
repositories {
jcenter()
maven {
url = "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
}
After update Android Studio and Gradle\Building mechanisms i can't build\make a project with set of similar errors like -
Error:(53, 24) error: cannot find symbol class ChartFactory
for every java class, where i do the "import org.achartengine.ChartFactory"
I have tryed add "compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'"
I have tryed Invalidate caches\Restart and Clean\Rebuild project,
i have changed syntax in tag maven and add symbol "=" after url.
It doesn't work still.
Gradle 3.X or 4.X do not see including of libs in way of:
maven {
url = "https://repository-achartengine.forge.cloudbees.com/snapshot/"
Please help me with that issue.
I have solved a problem. Thanks to #YaronRecher for hint about missing a real maven dependency on adress - https://repository-achartengine.forge.cloudbees.com/snapshot/
After every Studio \ Gradle Engine update your project do repeat its import from Maven repository. So if you're using AChartEngine and have updated Android Studio to 3.X your project wouldn't find anything on "https://repository-achartengine.forge.cloudbees.com/snapshot/"
Solution:
1) take JAR from https://github.com/ddanny/achartengine/files/460139/achartengine-1.2.0.zip and put in folder "app/lib" in your project;
2) Add jar in Studio via "File-Project Scructure", after - menu Modules-app and dependencies (button "plus")
3) Delete real folder .gradle in project and after use Clean and Rebuild (in "Build" Menu)
4) Look your build.gladle file (Module:App) and make sure that you have:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha2'
implementation files('libs/achartengine-1.2.0.jar')
}
and
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
...
testCompile 'junit:junit:4.12'
}
Enjoy!

Stetho-Timber library issue with new Timber version 4.1.2

While I was trying to use stetho-timber Library in my Android application I faced this problem:
Error:Module 'com.facebook.stetho:stetho-timber:1.3.1' depends on one
or more Android Libraries but is a jar
What's wrong?!
After inspecting in its codes I found that it uses timber v3.0.1!
Just add this to your build.gradle dependencies tag to exclude timber within the stetho library,
cause it is an old version and conflicts with new one:
dependencies {
compile ("com.facebook.stetho:stetho-timber:1.3.1") {
exclude group: "com.jakewharton.timber", module: "timber"
}
.
.
.
I have recently found Facebook Stetho Library and using it is fantastic, give it a try! :)

Android Studio cannot find AAR packages

I am having a problem with Android Studio recognizing classes inside an #aar library imported locally.
So... I've made a library and exported is an aar file. Inside android studio I selected Import Module and them Import .JAR or .AAR Package.
The project compiles and works with the classes inside the aar file but Android studio can not find the classes or offer any auto completion of so all.
Here is a few of screenshots:
The same problem also happens with other #aar libraries imported the same way:
Any suggestions?
Edit:
build.gradle:
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':UpPlatformSdk')
compile project(':simpleorm')
... // more libraries here
}
settings.gradle:
include ':app', ':UpPlatformSdk', ':wear', ':simpleorm'
Looks like you could do this How to manually include external aar package using new Gradle Android Build System
If you have them in your lib folder
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'UpPlatformSdk', ext:'aar')
}
This may not be the quickest way, but this works for autocompletion and also solved my problem of missing classes when I tried compiling my local AAR using the method #puj described. Essentially you need to create a local Maven repository to host the AAR, but any changes you make are pulled by the build system when you do a Gradle sync.
Android Library AAR depending on another library

How to add library to project in Android Studio 1.0.2?

First, this is not duplicate. I have browsed answers to "How to add library to project in Android Studio" but found no answer. I cant find src and libs folder. I want to add volley jar to project. Screenshot attached:
http://i.stack.imgur.com/2SyUp.png
For preferred way read bellow this answer:
If you need to add a library to the Android Studio project navigate to your project folder with default path at:
\YourProjectName\app\libs
You can paste your *.jar library there. Make sure your build.gradle contain this directive at dependencies part:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
To see the library at the Android Studio, switch to the "Project" view at the menu:
Preffered way:
Preferred way to import libraries to your project is by gradle dependency system.
To do so, open your build.gradle file and locate the dependencies part. To import the library you mentioned, Volley, your dependencies part should look somehow like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.10'
}
You don't need to import the *.jar library manually any more. Gradle dependencies system will take care of it.
To find gradle dependency you need, you might use tools like:
http://gradleplease.appspot.com/
http://search.maven.org/

Different dependencies for debug and release in gradle and Android Studio

I have an Android project, that depends on pure Java project. Both of them depend on another Java library, also in my multiproject gradle set in Android Studio. I have two versions of that library and want both Android and Java projects to depend on one of them in debug mode, and another - in release.
Is it possible for Android project? For pure Java project? How?
Build Types (debug, release, or custom) can have their own dependencies.
To specify a dependency specific to a build type, do the following:
dependencies {
debugCompile "mydebugdependency"
releaseCompile "myreleasedependency"
}
If your java project and android project are both using gradle, you can do the above in both of their build.gradle files.
My buildDebug dependency was also getting ignored. My setup is the app module and a library module, and I have the need to propagate the build type from the app to the library modules, i.e., when I compile the debug type on the app I want to get the library debug type too.
As mentioned, I tried having a specific dependency for each build type on the app gradle file, but to no avail:
buildTypes {
debug {
debuggable true
applicationIdSuffix ".debug"
dependencies {
debugCompile project(":library")
}
}
}
Ultimately what did the trick for me was this: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication
So, now the library dependency is managed (as usual) in the global dependencies scope in the app gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
releaseCompile project(path: ':library', configuration: 'release')
debugCompile project(path: ':library', configuration: 'debug')
}
and had to add this to the library's gradle build file:
android {
publishNonDefault true
}
This publishes all of the dependencies' build types. Note that if it takes a lot of time to compile your dependency, this solution might not be right for you.
You are able to do this using next pattern
build_variant_name dependency_configurations "dependency"
build_variant_name dependency_configurations project(path: ':libName', configuration: 'build_variant_name of libName')
For example
dependencies {
FreeDebugImplementation "dependency"
PaidReleaseApi project(path: ':libName', configuration: 'release')
}
You can read more about
build variants - https://developer.android.com/studio/build/build-variants
dependency configurations - https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration#new_configurations

Categories

Resources