How to import & use github repos in Android Studio - java

I've spent hours trying to import/use a custom github repo for an android app and am having no luck. I'm new to Android Studio but can't seem to import the repo such that I can use its methods. I've tried a lot of recommendations from here and the wider web without success. Probably because the posts I have come across are 5+ years old...
Have tried adding the following to to build.gradle (:app), but I get an error "Failed to resolve: com.github.pkleczko:CustomGauge:1.0.4":
implementation 'com.github.pkleczko:CustomGauge:1.0.4'
Have tried adding the the following to the above, but this gives me the error "Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app\build.gradle'":
repositories {
mavenCentral()
}
Have tried using New -> Import Module and New -> Project from Version Control per this, but these just opened the repo in a new window.
Having CustomGuage as a dependency for my app module didn't seem to do anything either.
It shouldn't be this hard, should it?! Please help, what am I doing wrong?! Do I need to import the project and then refactor it for my needs rather than using it as a 'library'? Do I need to add an import statement to my java file?
Thank you!

This is an old project. You can see his warehouse introduction. He uploaded it in jcenter. Of course, mavenCentral will not.
this is repository -> pkleczko/CustomGauge

Related

Gradle project import work in IDEA, but don't work in VS Code

I have this gradle java project with this setting.gradle
pluginManagement {
repositories {
maven {
url "${settings.ext.get("artifactory.contextUrl")}/example"
credentials {
username = 'myemail'
password = 'mypassword'
}
}
}
When i import it into IDEA, everything works fine, but i want to import this project into VS Code, but when i try it, gradle build passed just like in IDEA, but it still shows many errors:
error
and java dont see imports imports
obviously it shouldn't be problem with project and config, but with vs code, cause like i said, IDEA import it normally, does any have idea?
I tried turn on nested projects in vs code gradle, but without change, really don't know where could be difference between IDEA and VSCODE gradle.
Install the Gradle for Java extension. Check to see if all dependencies are included.
For more information on using gradle in vscode see here.

Cannot resolve FirebaseFirestore Android

I followed the official firebase android guide, but whenever I try to instantiate the FirebaseFirestore, I get a "cannot resolve symbol" error. The issue is as shown below:
Before this is marked as a duplicate, I have been searching for a solution to this issue for hours now. Nothing I found online works. Below is my gradle config:
app:
root:
Is there any idea what I am doing wrong? I have tried various different plugin versions for fireStore and firebase app but nothing seems to work
it all hints for, that the artifact had not yet been downloaded...
check if Gradle isn't in offline mode; and sync or build the project once.
alternatively, run ./gradlew clean assembleDebug from a terminal.
repository mavenCentral() is also rather relevant than mavenLocal().
while the repository for these artifacts should be the google() one.
another known issue is, that one may have to prefer IPv4, in the gradle.properties file:
org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true
Try adding this to your gradle
The FirestoreRecyclerAdapter class is part of the FirebaseUI Library but not the core Firestore SDK
implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
Try close your project and reimport it again
Looks like you have missed import statement
import com.google.firebase.firestore.FirebaseFirestore;
Try this:-
In Android Studio, click on File.
Then click Sync Project with Gradle Files.
I Recently Had that Error and this are the steps that I tried, I am not pretty sure which one of these did the trick but the error was solved and I was able to utilize fireStore. These are not in any Order I just randomly continued doing these.
I hope these helps.
Check for these
1. Have You Installed Google Play Services and Google Repository.
Check for the Updated Version and install it if available.
2. Try to Match All the Versions in the gradle config: app ... for eg,
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-firestore:16.0.3'
Sync Those Files for Quite few times
3. Clear Caches and Restart the Android Studio IDE
Step 1:- Go to File Menu > Invalidate Caches/Restart..
Step 2:-
Click on Invalidate and Restart on the Window that Appears
This
will restart the project and rebuild it, Stay calm as this can take
quite a time.
After Following These Steps all my Error were Solved and I was able to instantiate the FirebaseFirestore.
project build.gradle
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}}
I recently faced this problem. There is a simple solution.
Add this to your app Gradle:
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
Import the following statement:
import com.google.firebase.firestore.FirebaseFirestore;
Thank me later :)

Using Java & Gradle to build a maven project from github

I need help with the following problem:
Right now, I want to use my Java Gradle Project to build this github-project:
https://github.com/PaperMC/Paper but the project but it's a maven project.
I found a plugin for adding github projects as dependencies but it fails here.
An alternative would be to use this jenkins here: https://ci.destroystokyo.com/job/Paper/
However here I'm struggling to make my gradle always use the newest build without having to reasign the chaning version numbers by hand.
Can someone help me out because I have no idea what and how to add to the build.gradle.
Thanks in advance!
Edit:
I found the Maven-Syntax for the correct pull here:
https://paper.readthedocs.io/en/paper-1.11/developers/#plugin-developers
But when I try to convert the information to Gradle I still fail when I try to leave out the version so that Gradle would fetch the latest one. Can someone provide a valid snipped for this? I have never done this before.
According to this guy, you can use a fake ivy repository.
As https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/paperclip.jar points on the latest build, just set up your repository like this :
repositories {
ivy {
url "https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/"
layout 'pattern' , {
ivy '[module]-ivy.xml'
artifact '[module](.[ext])'
}
}
}
And then, use the dependency (the group is not relevant here)
dependencies {
compile 'anything:paperclip'
}
It will get the right file
$ gradle build
Download https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/paperclip.jar
...

Cannot resolve dependencies in sample Google VR Project

I cloned the project from here git clone https://github.com/googlevr/gvr-android-sdk.git
I imported the gvr-android-sdk project into Android Studio:
Opening the buid.gradle for the samples-sdk-treasurehunt project I see the following dependencies:
dependencies {
compile 'com.google.vr:sdk-audio:1.60.1'
compile 'com.google.vr:sdk-base:1.60.1'
}
See image here:
What am I missing?
If you take a look at https://bintray.com/google/googlevr/sdk-audio
It shows that version 1.60.1 hasn't been pushed to the repository yet. Try setting the versions to 1.60.0 (the latest pushed version)
edit: you may have imported the wrong folder, you need to import the folder that you cloned the repository to (as you need to project-level build.gradle), instead of import gvr-treasurehunt import gvr-android-sdk
Subscribe to the recently create issue at https://github.com/googlevr/gvr-android-sdk/issues/431 where I've added an initial solution (change ALL dependency references to 1.60.1 to 1.60.0, not just for the sample you're building.

How to add and use MarkdownView android library

I am on Android Studio 1.5.1
falnatsheh/MarkdownView
In the project's readme at github its gives instructions for use. These don't cover actually adding the project .. and I am learning Android programming (in fact I am making an app to keep my notes, as a sort of second step after "hello world").
how do I add it to the project so that I can follow the instructions on the project's readme? My default attempt was to follow these instructions:
File -> New -> Import Module .. add as ":markdownview" in my case, add it to the app's build.gradle, and then that should be it according to the site.
But that doesn't work:
The project's readme starts by saying you should add "compile 'us.feras.mdv:markdownview:1.1.0'" to the dependencies file (I am assuming they mean the Module:app one)... which looks like another way to add ":markdownview" to me.. but I did that too (and that instead of the ":markdownview"). Still the symbol does not resolve.
how do I add it to the project so that I can follow the instructions on the project's readme?
Add the following to your app/build.gradle file:
dependencies {
compile 'us.feras.mdv:markdownview:1.1.0'
}
which looks like another way to add ":markdownview" to me
Not exactly, but close.
but I did that too (and that instead of the ":markdownview"). Still the symbol does not resolve.
As with everything else in Java, you need to add an import statement.
I just created a scrap project in Android Studio, accepting all defaults in the new-project wizard. I pasted the above snippet in app/build.gradle and let Android Studio sync with the project files. I then added a reference to MarkdownView in the Java file, and Android Studio picked up the import without issue.

Categories

Resources