I try to evaluate the performance of the Realm database for a specific project.
Everything works fine at the moment. I just miss one method. I need a function to get the needed space for storing my realm database.
In case of some other databases I can take the size of the files where it is stored in. How can I get the needed space for my specific realm database?
And more important for me is the version. Evertything I tried works just fine with version 0.88.0
I just need to add the following dependency to my modules gradle file.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided 'io.realm:realm-android:0.80.0'
...
}
If I change this to
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided 'io.realm:realm-android:2.2.0'
...
}
I got the following error:
Error:(24, 13) Failed to resolve: io.realm:realm-android:2.2.0-snapshot
How can I change to the newest version?
Because of debugging I got version 2.1.0 working for me. Hope that I can copy the classes of the TestProject to my bigger Evaluation Project without getting errors. If not I will report that.
But first, I need some code to get the needed diskspace for storing the whole database. I need this to compare it to other Databases.
To use Realm's SNAPSHOT version, you need to add their snapshot repository in your build gradle.
buildscript {
repositories {
jcenter()
maven {
url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
}
}
dependencies {
classpath "io.realm:realm-gradle-plugin:<version>-SNAPSHOT"
}
}
repositories {
jcenter()
maven {
url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
}
}
To use Realm in your project, you need to apply it as a Gradle plugin (since 0.88.0).
apply plugin: 'realm-android'
For more info, refer to the official documentation: https://realm.io/docs/java/latest/#installation
Remove the -SNAPSHOT part from the version and its actually 2.1.1 is the latest version as for now, so the main part should be
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:2.1.1"
}
}
They really have some issue with the realm-annotations-processor of version 2.2.0-SNAPSHOT (its missing, check here). The latest version they did provide is 2.0.2-SNAPSHOT and thus if you want to use the SNAPSHOT then you should use 2.0.2-SNAPSHOT version.
Related
Basically the problem is I cannot resolve GitHub dependency even though I added this to Project level build.gradle.
build.gradle (Project)
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
and app level build.gradle
dependencies {
implementation 'com.github.mukeshsolanki:country-picker-android:<latest-version>'
How can I fix this? What is this cause possibly? I already updated to the lastest version of Android Studio.
In the string implementation 'com.github.mukeshsolanki:country-picker-android:<latest-version>' at the app level build.gradle file you must replace <latest-version> substring with the actual version of the library. Currently the latest version is 2.0.1.
So the result string should be this: implementation 'com.github.mukeshsolanki:country-picker-android:2.0.1'
Yesterday I opened the Android project on another computer (files were on my onedrive, so I never 'moved' the files') to show the project to someone.
Now I reopened the project on my actual computer and lots of errors are generated (see image). The project worked fine before.
They were both windows computers.
I tried resyncing the gradle and rebuilding the project but the issue persists. What did I do wrong and more importantly: how to fix it (I'm very new to Android).
The strange thing is that I can still run the app without errors.
Any suggestions?
You are missing dependencies.
From the looks of it, you are missing Android Support dependencies and
Volley
Confirm your build.gradle has the appropriate library references and repos to pull it and that the new machine has the sdk installed as well.
If you are using pre-28 I would expect to see in your parent project gradle.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71' //if using kotlin
classpath 'com.google.gms:google-services:4.1.0' //if using google services
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {url 'https://maven.google.com/'} //older android studio
maven { url "https://jitpack.io" } //post api 28 needed
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Then in your app level build.gradle you should have dependencies to get your volley and support libraries like the following example if you are post API 28:
NOTE* If you are pre-28 then update the namespaces to non-androix pathways.
dependencies {
implementation 'com.google.firebase:firebase-crash:16.2.1' //crash reporting
//to compile #synchronized things and java references
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.0"
//Android ui support
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
//Networking
implementation 'com.android.volley:volley:1.1.1'
// [START firebase]
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-appindexing:16.0.2'
implementation 'com.google.android.gms:play-services-base:15.0.2'
// [END firebase]
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
}
Then whenever you open on a new machine just check that you have the SDK path accurate. For example the local.properties should never be checked into the repo as it has a hard coded path for your "local" properties.
Next make sure your SDK path is good in the menu, it's the folder with the 3 little blue squares:
If all of these are good, then do a build.clean and rebuild to see if that clears you up. If you still have issues you can try
File->Invalidate Cache and Reset
Lastly, if that still doesn't work, you may have build cache issues, so delete all your iml files, idea files, build folders and import the project fresh from code only. I'm guessing you are copying the physical folder of the project from one computer to another which would cause issues.
Hope that helps.
Happy Coding.
I have this library I want to use, I can install one version, but the developer released a recent SNAPSHOT version, how can I compile it?
I've tried compile 'com.(...):1.4.0-SNAPSHOT without results?
Since SNAPSHOT is a Maven concept, it isn't treated as anything special in repository.
The best way to tell Gradle to check for updated version of a dependency is to flag the dependency as changing. Gradle will then check for updates every 24 hours, this can be configured using the resolutionStrategy DSL.
Override default module caching in Gradle:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
Then, latest.integration will work with each SNAPSHOT:
dependencies {
compile ('projGroup:projName:latest.integration') { changing = true }
}
For example in your case, projGroup is com.prolificinteractive and projName is material-calendarview.
dependencies {
compile('com.prolificinteractive:material-calendarview:1.4.0-SNAPSHOT') { changing = true }
}
Edit:
Another problem is that bringing latest release on the central repository defined, this repository actually not contain the SNAPSHOT repository where the -SNAPSHOT was located. So that you should add to your gradle repositories section the repository URL to allow download the SNAPSHOT version uploaded.
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
I'm trying to include Android Asynchronous Http Client and Picasso into my Android project using Gradle. Here's my build.gradle file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
dependencies {
compile 'com.loopj.android:android-async-http:1.4.4'
compile 'com.squareup.picasso:picasso:2.1.1'
}
}
When I try to sync it, I keep getting the following error.
No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [com.loopj.android:android-async-http:1.4.4]
Possible solutions: module(java.lang.Object)
I'm very new to Android so I'm clueless on how to correct this. Can anyone please help me out? I'm using Android Studio version 0.5.8 by the way.
Thank you.
Don't include dependencies in your top-level build file. Include them in module-level build files instead. If you use the Project Structure UI instead of modifying build files directly, it will set things up properly.
My Android app is based on Gradle and it just takes ages to build every time. This is due to the number of modules I have. Even if there are no changes in submodules, it keeps rebuilding every sources.
I was wondering if there is any way to convert these modules to local snapshot dependencies as I'm not updating them often?
I'm pretty sure it's possible but I have a very basic experience with gradle and maven so I can't figure out a simple way to do that.
Basically right now I'm listing my dependencies like that:
dependencies {
compile project(':Library:lib1')
compile project(':Library:lib2')
compile project(':Library:lib3')
}
and I'd like to use something like that:
repositories {
local()
}
dependencies {
compile 'com.lib1:lib:SNAPSHOT-1.0')
compile 'com.lib2:lib:SNAPSHOT-1.0')
compile 'com.lib3:lib:SNAPSHOT-1.0')
}
To use local snapshots use the maven-publish plugin. If you use SNAPSHOT in the version (e.g. 0.0.1-SNAPSHOT) you will publish snapshots to your local repository. For the build.gradle for lib1 you should do something like this:
apply plugin: 'java'
apply plugin: 'maven-publish'
project.version=0.0.1-SNAPSHOT
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
and run the :publishMavenPublicationToMavenLocal target.
In you gradle build file for projects using the library use:
repositories {
local()
}
dependencies {
compile group: 'com.lib1', name: 'lib', version: 'SNAPSHOT-0.0.1', changing: true
}
The 'changing' attribute indicates that not a cached version is used (normally updated once every 24hrs) but always checks for the latest.