React native link creates duplicated entries - android

I don't know why react-native link is creating duplicated entries in MainApplication.java (at imports and in getPackages function) and in app\build.gradle the compile project entry is not being added, but if I run again the command, I receive the same message instead of that the module is already linked.
When I run react-native link, I receive the messages that the module has been linked successfully on Android (duplicated) and in iOS it was already linked.

Many users are encountering the issue on Android (me included). It is due to difference between iOs and Android code-signin.
There is an opened (and recent) PR for this on the react-native project https://github.com/facebook/react-native/pull/18131 - hopefully it will be merged soon!

Faced a similar issue when I tried to link a library to my code. On running the react-native link command, it displayed that the library has been linked successfully though the entries were never created. What I did was to manually modify these 3 files:
android/settings.gradle: Add the module using include() and specify the path of your project directory.
include ':your_package_name'
project(':your_package_name').projectDir = new File(rootProject.projectDir,'../node_modules/your_package_name')
android/app/build.gradle: Add the compile statement
compile project(':your_package_name')
android/app/src/main/java/[..project_name..]/MainApplication.java: Import the package and make sure that the getPackages() is returning your package along with the previous ones.
Would have answered you better if you specified the name of the required library

In my case, It was related with RN version and local libraries.
I solved it by removing the duplicated libraries on Xcode.
Here is link
Hope it give you some help.

Related

Being to foolish to correctly implement a module library into my project

I recently started developing my really first Android Project using Android Studio 3.1.2.
Therefore I implemented a module library into my app, by cloning it from github, imported it as module library and added a dependency via right-click on app > module settings, switch to dependency tab, hit the +, select imported_module.
Additionally I checked my build.gradle(Module:app), if the dependency has been added correctly, there this line appeared:
dependencies {
...
implementation project(':imported_module')
}
Also in the settings.gradle file it says:
include ':app', ':imported_module'
Now if I want to access features of imported_module any of them can't be resolved. I browsed the official and the common forums for hours to find the one step I obviously missed but wasn't smart enough to find the solution.
Synching the project with gradle files didn't cause any visible effects
What do I still have to do to be able to use all the fancy stuff fro imported_module inside my app? Do I have to import it in a certain way?
Or do I have to modify my AndroidManifest of my app somehow? Thanks in forward!
EDIT: could it be that my app and imported_module obviously have different package names? The Project File Tree says com.domain.example.my_app for the app and com.domain.example.imported_module for imported_module. Do I have to squeeze the one into the other?
It could have been much easier, if you had mentioned what exactly you want to access in main app. May be access specifier of the member in your imported_module is private.
I kinda worked around the whole thing, by just adding a remote dependency in my build.gradle file of a new project, pasted my java classes and my res into this new project, synched it and now it runs. Nevertheless thanks for thy help!
That should be really all. Be sure to sync your project with Gradle files (File - Sync Project with Gradle Files).

Crashlytics libraries not recreated in my project using eclipse

I'm using Crashlytics (part of Fabric now) in my eclipse Android project. The four automatically added Crashlytics libraries don't get recreated in my project after deleting them from file system.
Restart eclipse doesn't help
Reinstalling Fabric plugin doesn't help
The plugin says it's installed correctly, but I can't import:
io.fabric.sdk.android.Fabric;
com.crashlytics.android.Crashlytics;
Has anybody come to a similar situation?
Detailed description of how that happened for me:
When I installed the plugin for the first time, the plugin integrated into my project. It added a couple of .properties files and also 4 libraries (nested them weirdly to my project folder under /kit-libs/ and also added them to my workspace even though just one was set as a library project to my project).. Uhh, well, can't say I like this way of integration.
Anyway, I removed these automatically created libraries because I switched to an old commit of my project which hadn't used Fabric at that time and I needed to make a build quickly. I don't use any build tools for this project and I didn't find any information about how to remove the plugin, so I just deleted the libraries from file system and removed the library project.
When I switched back to current commit, the libraries got recreated. But I needed to do the same thing once again, so I switched to an old commit, deleted the library folders, removed library project and did my thing. However, after I switched back to a new commit, the 4 libraries don't get recreated anymore.
Will be glad for any tips.
I eventually managed to get the libraries back to my project by checking out another commit (which included them).
After the library folders were back, I added /kit-libs/com-crashlytics-sdk-android_crashlytics as a library project to my project and everything worked again.
Now thinking about it, it may have been git's fault.
I also contacted Fabric support team and this is what they replied:
Try onboarding that app again by going to the plugin and clicking +
New App in the right hand side. If you've removed all traces of
Fabric, you should be able to re-onboard it, no problem.
However, I believe I removed all traces of Fabric, tried this and it didn't work - added my app to Fabric again, but it didn't recreate the libraries. It's hard to say what they mean by all traces of
Fabric, it's not documented anywhere. Possibly it's:
/assets/crashlytics-build.properties (*)
/kit-libs
/res/values/com_crashlytics_export_strings.xml (*)
/crashlytics.properties
/kits.properties
That's what I particularly don't like about this tool, it spreads its files all over the shop without you even knowing.
Another thing is, they also don't explicitly tell you that you shouldn't commit two of these files (*) to source control. You find out only by exploring the new files and noticing a comment:
Do NOT modify, delete, or commit to source control!
I had a similar issue, but my requirement was not to allow the twitter kit provided by Crashlytics (Fabric) to recreate itself every time i start eclipse.
I tried deleting the libraries from kit-libs but every time i restart eclipse the twitter kit was automatically added back into my project. I dug deep into the issue and found that there is file called kits.properties (you can find this next to your manifest file or somewhere down the lane).
This file specifies the Crashlytics libraries that needs to be loaded into your project. In my case i removed the package name com.twitter.sdk.android:twitter:1.1.0 (i only needed the twitter kit to be removed) which eventually stopped the re-creating process.
For your case, you need to put back the line com.crashlytics.sdk.android:crashlytics:2.1.0 into the file and restart eclipse for the library to be recreated. Please note, the package specified varies based on your installed version. The package name given above is the most recent one.
I had similar issue com-crashlytics-sdk-android_beta is deleted and project starts giving error that the com-crashlytics-sdk-android_beta file not found.
I cleaned all projects and this makes every thing working fine. Fabic added new library for the project.
Clean projects Step:
1) Go to Projects in eclipse from menu.
2) Click Clean.
3) Select clean all projects.
I had a similar issues with the crashlytic libraries .jar files missing and not being re-built. The error message I got was: "The container 'Android Dependencies' references non existing library" for com-crashlytics-sdk-android_answers, _beta, _crashlytics, _crashlytics-core.
After many tries and searches over several days, I tried again and there was an upgrade of crashlytic. The upgrade itself did not solve the issue but the steps described by ValayPatel and georgiecasey in this post (note, I'm not working with any facebook APIs in my app):
The container 'Android Dependencies' references non existing library 'facebook-android-sdk\facebook\bin\com_facebook_android.jar'
it worked! Thanks to both!
Hope it helps who ever else gets that problem...

How do I import com.google.android.gms.* in Android Studio using a Gradle build?

I have followed the procedure as described here : Setup
I have clicked on the little 'Sync project with Gradle' button. Gradle and Android Studio seem to find everything but then I can't actually use the gms code. If I try to import, I will get autocomplete for com.google.android.gms but no further. I have updated all the packages with Android SDK Manager.
I'm running Android Studio 0.4.2.
My minSdk is set to 9
my build.gradle includes compile 'com.google.android.gms:play-services:4.0.30'
As far as the procedure is concerned I should be ready to code, but it just doesn't work. Any ideas?
[Edit, added info]
I can find the ComGoogleAndroiddGmsPlayServices3265.aar file in my exploded bundles directory. Inside of that file I also find the common directory and inside that I find the GooglePlayServicesUtil.class (which is what's not being found in my app)
I am lost.
[Edit 2]
The problem is not specific to Google Play Services OR Android Studio. I tried adding another library (HoloColorPicker) and had the same results. However, I was able to add the library's resources to my project! I was able to add them in my XML layouts and view them in my application. I was able to interact with them, they worked fine. The problem arose again when I tried to reference them in the code. Exactly like the case with gms, I had code completion when trying to import up to the point of the actual class, and I could not declare the class in the code.
I was able to use the library by cloning it and importing the project.
Also, this is not an Android Studio problem because the same thing happens on the command line with "./gradlew clean build"
This is a current bug in Android Studio: https://code.google.com/p/android/issues/detail?id=64508 to be fixed this week.
The workaround is to close the project, delete the .iml files and .idea project and re-import the project.
Keep Your compile 'com.google.android.gms:play-services:4.0.30' as very first line in build.gradle dependencies like
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:+'
}
`
Open File> Project Structure and do the following steps
Select your main module in which you want to add dependency and click on OK.
Now try to import.
I think the most important question is what you want to achieve. Not all code is under this package. Not even sure which one is.
As noted before, this is a bug with Android Studio. It just don't recognize the path for classes and shows you like if there is an error. If you try compiling you'll see that everything just work fine.
A googler recently said it'll be addressed in this week release, so, be patient and lets see whats coming.
The fact that AS is in Preview mode tell us this sort of things are going to happen :)
Android studio is crazy one, I think.
It's removed "Import module" function and you can do "New module" only.
If you are developed on Eclipse, you need export all your projects to Gradle before switch to Androids studio (WTF?)
I prefer "IntelliJ IDEA Community Edition", although It's similar Android studio but it's better than Android studio (at least until now). You just import your project as eclipse format, IntelliJ IDEA will detect dependences libraries automatic (May be you need import jar libraries by hand) and rebuild project. That Done.

how can I add the aidl file to Android studio (from the in-app billing example)

I am currently migrating an Eclipse app to Android Studio.
This app was using the in app billing.
My main problem is to compile the project and the aidl file (I guess you all use this file)
I get this error message:
Gradle: error: cannot find symbol class IInAppBillingService
Gradle: error: package IInAppBillingService does not exist
So, following some tutorials, I move this file from com.mypackage.billing to src/main/aidl
(see this reference)
But as soon, as I do that, I get this message:
Gradle: Execution failed for task ':xxxxxxxxxxx:compileDebugAidl'.
Failed to run command:
(...) C:\Users\xxxx\AndroidStudioProjects\xxxxxxProject\xxxxxxx\src\main\aidl\IInAppBillingService.aidl:45
interface IInAppBillingService should be declared in a file called
com\xxxxxxxx\billing\IInAppBillingService.aidl.
The message is clearly a contradiction with the post from the Google bug page I linked above.
Anyone suceeded to make this aidl file to work and can help me?
Just to inform, some links I followed:
http://tools.android.com/tech-docs/new-build-system/user-guide
http://developer.android.com/guide/components/aidl.html
Adding this as an answer since it seemed to help quite a few people.
Create a new directory named 'aidl' under 'src/main/'. It should look like 'src/main/aidl'.
Add a new package name 'com.android.vending.billing' to the directory 'src/main/aidl'
Locate your sdk location and go to "sdk\extras\google\play_billing". Default location for the sdk is "C:\Program Files (x86)\Android\android-sdk". If you custom changed it, then you will have to figure out the location through the sdk manager.
Copy 'IInAppBillingService.aidl' into the package created above. In the end, it should look similar to the image below.
Rebuild project and it should be good to go.
Note: Make sure you include the necessary import if your reference isn't working
import com.android.vending.billing.IInAppBillingService;
https://issuetracker.google.com/issues/36973270
Edit From Comment
After I did this, the references to IInAppBillingService in my code were still highlighted as errors, but after rebuilding the app, the class was recognized
Just as the error message says, you need to put IInAppBillingService.aidl in the correct directory dictated by it's package (com.android.vending.billing).
Within the src/main/aidl/ folder you already have, put the .aidl file in com/android/vending/billing/.
Create new directory under src/main called aidl
Right click on directory aidl, select new->add package
Enter Name of the package com.android.vending.billing
Copy IInAppBillingService.aidl from the directory Android/Sdk/extras/google/play_billing to the directory App_name/app/src/main/aidl/com/android/vending/billing
Now go ahead with InApp billing coding and while defining InApp related services you will get an error can not resolve symbol IInAppBillingXXXXXX
Now goto to Build from android studio menu , click on Rebuild Project. This will generate IInAppBillingService.java file inside App_Name/app/build/generated/source/aidl/debug/com/android/vending/billing. This will solve the issue.
The rest of posts here didn't work for me till I created a new folder like shown here.
Add this code in build.gradle
android {
sourceSets {
main {
aidl.srcDirs = ['src']
}
}
}
Rebuild and import aidl class
The above answers concentrate on file location, but it appears you already had that set correctly. I experienced this same issue in Android Studio, but none of the listed answers resolved it, and I banged my head against it for an hour. Eventually, I realized that I was missing an obvious import:
import com.android.vending.billing.IInAppBillingService;
Once I added that it resolved this error message.
This import isn't mentioned in any of the Google Billing docs or included in any of the code examples that I found. While it may be obvious to experienced Java developers, beginners just trying to learn their first project may need it explicitly pointed out.
We need to add
create folder - src/main/aidl/packagename and place aidl file under this.
In the aidl file - mention the package name.
package packagename
Now clean the project, rebuild the project - We can the corresponding java file for the aidl generated in app\build\generated\source\aidl\debug\packagename\youraidl.java
I know it sounds so easy, but I copy paste from google sample all folder
https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive/app/src/main
aidl/com/android/vending/billing
copied into project aidl ( I had set project view in Android Studio)
and next I clean and rebuild project and it found a reference.
I've tried every solutions, but the problem was that Android Studio had compiled, with any apparent reason, in a different build type of the module that contains the AIDL packages than it was specified by the settings.
From debug to release, so the other modules couldn't see the AIDL pkg.
Switching from debug to release and turns back, solved my problem.
restarting Android Studio worked for me
a second silly thing that took me a while. I dropped the code on Android Studio to allow him create the file, but he created a .java (as expected) instead a .aidl Jiji, stupid of me
if you do all the names correct go to Build>rebuild project
it worked for me
I use Android Studio 4.1, just right click mouse -> New -> AIDL -> AIDL File.
A file will be created and placed in the [src/main/aidl] folder automatically. The aidl folder will also be created if it does not exist.
This function only supports min sdk 16+. My old project still can be supported, you can temporarily modify the min sdk to 16, create aidl and build project. After the relative interface and class be generated, recover the min sdk settings, it also works and builds project well then.

Where can I get a JAR to import libcore.io?

I want to handle an GaiException in my App. The debugger tells me, it lives in the libcore.io package, but importing it yields an error. I guess I need to add an additional JAR to my projct to correctly resolve this type. I've been digging a bit in my android sdk folder, but don't seem to find anything of the kind.
Thanks for any advice.
If you are using android studio you can add this line to your gradle build (under dependencies).
compile 'org.robovm:robovm-rt:+'
If using Eclipse, check this Maven link and add it however is appropriate.

Categories

Resources