Why doesn't Android recognize "BillingClient" - android

I am following this guide.
https://developer.android.com/google/play/billing/integrate
my build.gradle looks like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
implementation "com.google.android.gms:play-services-ads:19.6.0"
implementation "com.android.billingclient:billing:3.0.0"
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
}
The Java code in Android Studios 4 does not have recommended imports for BillingClient
If I try this:
import android.billingclient ...
"billingclient" shows up red / unrecognized.
If I try this:
import androidx.billingclient ...
"billingclient" shows up red / unrecognized.
If I try this:
import import com.android.billingclient ...
"android" shows up red / unrecognized.
I am trying to port a game to Android. I have been stuck on this for days. Any help is greatly appreciated!!!
Please help!! Thanks!!

Okay, I have figured it out. After literally days.
All it was is "File>Sync Project With Gradle Files"
I am not sure why I didn't need to do this for other statements I added to gradle.

Related

Android Studio Javadoc won't generate because "Selected scope contain no Java classes"

I am trying to generate the JavaDoc for the Activity class source code in Android Studio 3.6.3. The file is open in the editor, and I use "Tools | Generate JavaDoc".
When I click OK, it fails with the message "Error running 'Javadoc': Selected scope contain no Java classes". I also tried the "Custom Scope" option with "Current File" choice, but same results.
Can someone help why can I not generate the JavaDoc for this file?
The file is too large to paste here, it is 410832 characters, only 30000 allowed.
I could paste some of it if that would help.
I think maybe JavaDocs needs compiled code with no errors, missing references, etc. When I open Activity.java, It is not compilable.
Thanks for the idea. It was someone else's code, so I looked at another project of mine where the build.gradle file for the module has:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Then I followed the declaration chain in my code for an Activity up to the Activity superclass -- and it goes to the same source file. I guess my SDK has one source file regardless of the library used. Anyway, same problem, it won't print the JavaDoc. I don't understand why it won't print that source file, since it exists.

error: package android.support.v7.widget does not exist

I'm trying to use an SDK given with the RFID scanner I recently bought.
I'm trying to run the sample code given, but it won't compile. I get the following errors on compilation:
error: package android.support.v7.widget does not exist
error: package RecyclerView does not exist
I've tried all the solutions on similar posts, and I'm pretty sure I have the support library correctly installed.
Here are all my dependencies in my build.gradle (app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.material:material:1.1.0-alpha08'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation project(':Rfid.AsciiProtocol-Library')
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.android.support:recyclerview-v7:26.0.0'
}
I'm new to Android Studio, and as I said I tried pretty much all the answers for similar problems and nothing works. Any help welcome :)
Thanks a lot in advance,
Cyril
You should replace android support recyclerview with androidx
implementation 'androidx.recyclerview:recyclerview:1.0.0'
And you can delete 'com.android.support:appcompat-v7:+' dependency, because you've already import it with
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
It frustrated me for literally hours because the answer here given is missing so much.
In dependencies of gradle:
import:
implementation 'androidx.recyclerview:recyclerview:1.0.0'
click gradle sync (should be a bar on top of the page that pops up
Then in your java file where u actually use the RecyclerView class, import this:
import androidx.recyclerview.widget.RecyclerView;
and you are done
EDIT: So apprently you just need to auto-fill the object you need and android studio will auto inport for you. example:
try to type recyclerview, but press tab to auto-fill it. The object should automatically be imported for you on top of the java page. This works with all android studio objects like view and intent.

How to fix appcompat gradle error? android 3.4

Having continuous problems with my gradle. The
implementation 'com.android.support:appcompat-v7:28.0.0'
is underlined in red
This is stopping me from continuing in my development (i'm still very new to android). My problem initially started with
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
being underline in red and causing an error, but changing my import to
import androidx.fragment.app.FragmentActivity;
cured the problem, but my gradle still is having build problems. I have android 3.4, and my gradle wrapper is 5.1.1. I have no idea how to stop the error from occurring and getting rid of my gradle errors.
I've changed it to alpha1, rc01 and tried downgrading the version but its not working.
The dependencies is where my problem is occuring:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha7'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I just want the gradle to full work and be able to move on haha, I've been trying to fix this for a while...
You are still using older support libraries hence the errors persist even in the app level Gradle file. Add these to your Gradle:
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
After replacing these with your current implementations in your Gradle, sync the project. After that, clean/rebuild the cache.
Now the code you have wrote is most likely going to give error because the code was using older support library which is no longer in your project. To solve it, you need to rewrite the error code but this time using androidx imports.
You need to refactor your project to androidx
Go to Refactor -> Migrate to androidx
Click on Migrate

How to change default dependencies implementations when starting new projects

When I create a new project the activity_main.xml file does not show the default "Hello World!" TextView. I found a video which corrected this by changing an "implementation" line in the build.gradle (Module:app) file. He changed the end of the second implementation line from beta01 to alpha1.
`dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}`
I suspect that some setting is off, either in the way I configure new projects to build, or some other possibility I'm completely unaware of. Is there a way to change what defaults under dependencies on a new project build? I'm not certain if this is the cause of the problem, or the symptom of a larger one. I cannot seem to follow the simplest of tutorials three steps in before getting errors which seem simple, but I cannot seem to resolve.
I'm new to Android and have some experience coding. I'm quite lost, however, because I can't seem to follow alongside simple tutorials. Any help would be great.
I'm using Android Studio 3.1.4
The video I reference (near 45s to 1m in): https://www.youtube.com/watch?v=dpGqlBDqz_M&t=80s
I've also checked out the Gradle doc's to no avail: https://docs.gradle.org/current/userguide/declaring_dependencies.html

Android Studio: import com.android.volley.xxxx Cannot Resolve Symbol 'xxxx'

So, I followed this tutorial to create a ListView with images using Volley but I am having this issue with the com.android.volley.xxxx import statements in LruBitmapCache.java, AppController.java, CustomListAdapter.java, and MainActivity.java. It shows as Unused import statements and its extension are in red saying Cannot resolve symbol xxxx. Volley.jar is already aded to app -> libs section.
Would appreciate any help.
I'd double check to make sure your build.gradle includes:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
...
}
And also make sure you've ran a sync.
Add
compile 'com.mcxiaoke.volley:library:1.0.6#aar'
to your Gradle dependencies...
Add this in your build.gradle of your app
https://developer.android.com/training/volley/
implementation 'com.android.volley:volley:1.1.1'

Categories

Resources