How do you include Android N source code inside Android Studio? - android

How do you include/download the Android N source code when developing inside Android Studio?
The documentation/source code isn't currently available inside the Android SDK Manager.
#Passer by Thanks for announcement, I managed to download like that :

Source code for Android N is now available from the SDK.

Currently, there is no available documentation and SDK sources code to download from SDK Manager, only compiled SDK and samples (see GitHub). But you can use updated for N API Reference together with Android API Differences Report to figure out the code.
Update: Google pushed Android 7.0 to AOSP so you can now download the sources for API 24 from SDK Manager
To use N preview SDK in project, update your build.gradle as below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-N'
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.alvenir.myapplication"
minSdkVersion 'N'
targetSdkVersion 'N'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Related

Android Studio is changing my API level from 23 to 26

Thanks for stopping by. I have been working on an app at API 23. Now Android Studio is "upgrading" it to API 26. This is not what I want. I want to keep it at API 23. Everytime I make a new app its 26. Downgrading doesn't work; I get a bunch of errors.
Thanks
You can change it as you like.
1.Click on your project folder > app > build.gradle
An example of build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
2.Open your Android Studio, and go to Menu.
File >Project Structure. In project Structure window, select app module in the list given on left side.
Select the Flavors tab and under this you will have an option for setting “Min Sdk Version” and for setting “Target Sdk Version”.
Select both the versions and Click OK.
Keep in mind that if you're uploading it to the play store, it's going to have to target 26, soon to be 27. That's probably why AS is trying to update your version.

Is it necessary to first connect raspberry pi 3 with adb then develop the android things project

I am new to android things. Recently I tried to build an android things app on android studio 2.3.3 with 25 SDK.
But when I include the android things support library into the dependency of app module build.gradle file and sync with latest gradle changes,it gives me the below error :
"Install repository then Sync"
Plz Someone help me.
You don't need to connect Raspberry Pi to develop a Android Things project.
There are three points which you have to keep in mind while developing for Android Things:
Update your SDK tools to version 25.0.3 or higher.
Update your SDK with Android 8.0 (API 26) or higher.
In order to access new APIs for Things, you must create a project or modify an existing project that targets Android 8.0 (API level 26) or higher.
Add the library.
In your case, you need to install the latest bulid tools, and repositories to develop an Android Things Project.
Your build.gradle should look like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.android.androidthings.id"
minSdkVersion 21
targetSdkVersion 26
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:25.3.1'
provided 'com.google.android.things:androidthings:0.3-devpreview'
}

how to use marshmallow in Android studio

I am using Android studio and i want to use Marshmallow API and AppCompatActivity. When I created a new project the build.gradle contained the below lines but I receive error at R class which says not a symbol.
Please let me know how to correct the build.gradle to get the App work.
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.com.myapplication"
minSdkVersion 19
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'])
compile 'com.android.support:appcompat-v7:23.0.1'
}
Click on Build->Clean Project and that will perform a gradle clean
Update your Android SDK Manager Install all component of Android 6.0 (API 23)
R file can be erased due to many reasons, try rebuilding your project(which is the most common issue) and other issues may include any syntax error or inappropriate file permissions in work space, the exact error report can help address the issue better.

Android Studio: Can't install app on the Android device

SOLUTION
In build.gradle file, I set both minSdkVersion and targetSdkVersion to 19 (my Android device's API level).
Also, compileSdkVersion's value must be less than your device's level API.
Issue was:
I cannot install my app I developed in Android Studio, in my Android device (LG G3).
When I try to install my app, this window comes.
When I click OK, the log outputs this.
This was my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "*AppID*"
minSdkVersion 15
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
What I've tried to do:
1. Modify build.gradle to (Changed compileSdkVersion's value to 15):
apply plugin: 'com.android.application'
android {
compileSdkVersion 15
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "*AppID*"
minSdkVersion 15
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
2. Clean the project: i.imgur.com/lbdeXGe.png.
Take a look at Failure [INSTALL_FAILED_OLDER_SDK] Android-L
Recently there was a post here regarding the L SDK's incompatibility with prior versions of Android. I've been digging in
AOSP repositories for quite a few hours now, and determined that the
tools behave this way because they are designed to treat preview
platforms differently. If you compile against a preview SDK
(android-L), the build tools will lock minSdkVersion and
targetSdkVersion to that same API level. This results in the produced
application being unable to be installed on devices running older
releases of Android, even if your application isn't doing anything
specific to L. To make matters worse, the new support libs (CardView,
RecyclerView, Palette, etc.) are also locked into the L API level,
even though--according to their repository names--they should work on
API level 7 just fine (and they do!).
The error means your device has an Android version that is less than your specified minSdkVersion. Set the minSdkVersion to the device's version. If that's not possible, there's really nothing you can do other than using a newer device.
Edit:
Now seeing userM1433372's answer ... That should be the actual issue. Thought you already tried a different SDK version, but you only changed compileSdkVersion to 15 without changing targetSdkVersion! I would suggest setting both targetSdkVersion and compileSdkVersion to 19 (which is the latest non-preview-version).

Failure [INSTALL_FAILED_OLDER_SDK] when installing Android Wear sample app

I followed the instructions at this link to create a simple mobile/wearable app in Android Studio. However, upon trying to run it I am getting the error "Failure [INSTALL_FAILED_OLDER_SDK]". My problem seems to be like the one asked at this link, however unlike that user the reddit post that is linked to didn't contain any information that helped me (it basically suggested to add < uses-sdk tools:node="replace" /> to the android manifest, but android studio didn't like the tools thing." My build.gradle files are exactly the same as those at the above link. I just updated Android Studio today (0.8.2) and have installed all necessary SDK's. Many people are getting this error but mine is unique in that I'm targeting the Wear stuff and not concerned with Android L. Any input is appreciated. Thanks!
I believe I have the answer here. Basically instead of deploying to the phone like the instructions say to, you have to enable bluetooth debugging and deploy directly to the watch.
Do those changes in build.gradle file in the wear module
compileSdkVersion 20
targetSdkVersion 20
So the final wear/build.gradle content will be:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "your package name"
minSdkVersion 20
targetSdkVersion 20
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.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}

Categories

Resources