Room Persistence inside of Lib - android

I am looking for a good way to import Room Persistence inside of my Lib to export .aar . I have the following issue that .aar cannot handle dependencies.
When I export my arr and import into another project as lib, it seems as it has no scope to room.
my lib Gradle file :
apply plugin: 'com.android.library'
apply plugin: 'maven'
archivesBaseName = '*****'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 5
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Write out the current schema of Room
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
deployerJars
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'android.arch.persistence.room:runtime:1.1.0-beta3'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.0-beta3'
}
Thanks.

Related

Migrating to gradle 3.+ with libraries that compile different flavors

I have a very complex project with many libraries that are dependent on each other. I have gone through all of the documentation and videos but nothing is pointing me in the right direction to compile libraries based on flavors. I am confused with the project aspect. If anyone can point me in the right direction to update compile to implementation, that would be great. How do I directly replace configuration: to match the flavors?
Here in an example of two gradles.
vnfmdata
android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
publishNonDefault true
flavorDimensions flavor.default
productFlavors {
regular {}
no_meridian {}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
regularCompile project(':vncore')
regularCompile project(path: ':vnlocationservice', configuration: 'meridianDebug')
no_meridianCompile project(':vncore')
no_meridianCompile project(path: ':vnlocationservice', configuration: 'no_meridianDebug')
}
vnlocationservices
android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
publishNonDefault true
productFlavors {
no_meridian {}
meridian {}
}
buildTypes {
release {
//minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile deps.support.app_compat
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
no_meridianCompile project(':vncore')
meridianCompile project(':vncore')
meridianCompile project(':third:Sas-Android')
//Localytics
meridianCompile deps.support.compat_v26
meridianCompile deps.play.ads
meridianCompile deps.play.location
meridianCompile deps.localytics
///////////////////
meridianCompile 'com.arubanetworks.meridian:meridian:+#aar'
}
edit:
I found that adding a dependencies node into a flavor affected the other flavor. Instead it is better to use <flavor's name>Implementation.
As you stated, you probably went into the Migration Guide resolve matching errors.
vnfmdata
Here the changes are located on the flavors and how the dependencies changed:
android {
...
productFlavors {
regular {
// Forces regular's flavor to point on LocationService meridian's flavor
// because their flavors' name are different
matchingFallbacks = ["meridian"]
}
no_meridian {
// Will automatically point on LocationService no_meridian's flavor
// because they both have the same name
}
}
...
}
dependencies {
// We used the flavors' matching feature
// so gradle knows that if you select regular, you wants the meridian flavor on these 2 projects
implementation project (":vncore")
implementation project (":vnlocationservice")
}
vnlocationservices
Here we see how to declare a dependency which is only use by one flavor.
android {
...
productFlavors {
meridian {}
no_meridian {}
}
...
}
dependencies {
implementation project (":vncore")
meridianImplementation project(':third:Sas-Android')
//Localytics
meridianImplementation deps.support.compat_v26
meridianImplementation deps.play.ads
meridianImplementation deps.play.location
meridianImplementation deps.localytics
///////////////////
meridianImplementation 'com.arubanetworks.meridian:meridian:+#aar'
}
}

Error:(22, 0) Could not find method android() for arguments

here's my gradle file
I am getting this error
Error:(22, 0) Could not find method android() for arguments
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
defaultConfig {
minSdkVersion 26
targetSdkVersion 26
}
productFlavors {
}
}
dependencies {
}
You need to apply a plugin to your build.gradle file. Only then you will be able to use the android block. Add any of these two lines at the top of your build.gradle file:
Application : apply plugin: 'com.android.application'
Library : apply plugin: 'com.android.library'
Your App Gradle should look like something like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.armenhovhannisyan.backpaper.backpaper"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

Plugin not found when importing project as library in Android Studio

I am trying to integrate an application to another one. To do that I compiled the first one as a library and after that I added it to the dependencies of the application project after I added it as a module following some guides in stackoverflow.
The problem is that after doing that, I got an error about a missing plugin. Although I have researched a bit over google I have had no luck on that one.
The error is Error:(4, 0) Plugin with id 'com.google.protobuf' not found.
Open File
Both applications work very well, each on their own... What am I doing wrong ?
Here is my build graddle of the main app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.arlind.myapplication"
minSdkVersion 15
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:design:23.1.1'
}
Here is the build graddle of the added library
import java.text.SimpleDateFormat
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
}
}
android {
signingConfigs {
global {
keyAlias "Lind"
keyPassword "gators"
storeFile file("lindkey.keystore")
storePassword "gators"
}
}
compileSdkVersion 22
buildToolsVersion "23.0.0"
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.global
}
}
productFlavors {
catapult {
versionCode getLongDate().toInteger()
versionName '12.1-' + getShortDate()
}
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile project(path: ':wallpaperPicker')
}
sourceSets {
main {
manifest.srcFile '../AndroidManifest.xml'
java.srcDirs = ['../src', '../util', '../extra/src']
res.srcDirs = ['../res', '../extra/res']
proto {
srcDir '../protos'
}
}
}
}
def getDate(String dateFormat) {
def df = new SimpleDateFormat(dateFormat)
Calendar c = Calendar.getInstance();
TimeZone tz = c.getTimeZone();
df.setTimeZone(tz)
return df.format(new Date())
}
def getLongDate() {
return getDate("yyMMddHH")
}
def getShortDate() {
return getDate("yyMMdd")
}

Gradle DSL method not found: 'applicationId()'

I am getting this error on building the application in Android Studio.
Gradle DSL method not found: 'applicationId()'
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
applicationId "com.ms.knowursensor.android"
minSdkVersion 13
defaultConfig {
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "sensorgraph"
stl "c++_static"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk {
debuggable = true
}
}
debug {
debuggable true
jniDebuggable true
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/jniLibs'
// use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
This issue came when i recently update the SDK. How to resolve this issue?
Move applicationId and minSdkVersion into your defaultConfig closure.

I cant import the Facebook library

I´m following the next tutorial to use Facebook on my app, them, In the step five I write the line: compile 'com.facebook.android:facebook-android-sdk:4.0.0' but nothing happends and I can import the library in the step 6.
This is my build.grandle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
repositories {
mavenCentral()
}
defaultConfig {
applicationId "com.mookup.singup2"
minSdkVersion 14
targetSdkVersion 22
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:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
}
And in my MainAplication, I have this:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FacebookSdk.sdkInitialize(getApplicationContext());
}
I saw the dependencies and they say "compile", but I can´t import the facebook library.
Dependencies

Categories

Resources