Here it goes.. I am a bloody beginner in programming! So i am also new to android studio..
Here is what i've got:
I am playing around with those fragments and the navigation drawer, everything works just fine, but is it possible to import, lets call it a "whole" github project as fragment class ? Just copy and paste gave me too many errors for me to understand..
(A bit more detailed, i want to build a calendar app, and the android studio calendarview gives me no access to customize the view, so i wanted to use CompactCalenderView just for some testing..
Greetings PatPat!
Add this line to your app's build.gradle's dependency block
compile 'com.github.sundeepk:compact-calendar-view:1.7.9'
EDIT:
From Gudin's comment:
On the left side in your android studio open the "Project" tab, if its already open then you should see a file/folder structure on the left side, in the same tab there is a drop down which when you open there should be an option called android just click on it, Now you will be able to see a folder called Gradle scripts, expand it and open the build.gradle(Module:app)
First get take a good look the image ive provided
can you see that there are 2 build.gradle files? Saw that ??Good..
Now select that Gradle build with module:app file
Next put the dependencies in the dependency section just as i have done sync or rebuild the project and that pretty much it ..Hope this helps
Related
The issue is already answered for iOS:
How to embed framework in capacitor plugin for iOS
For Android, I get issues when I add an aar file to the capacitor plugin by creating a new module. After publishing my capacitor plugin via npm and integrating it into an ionic app, the aar library cannot be found anymore.
As done on iOs, we do practically the same thing here. But, using Android Studio and gradle instead of xcode and cocoapods.
Ok, but first things first.
When the command npx #capacitor/cli plugin:generate is issued, what the CLI does is to start a folder containing a cocoa pod for iOs and a gradle plugin for Android. You can see this on the image below.
With the above command issued, there will be a ios and android folders inside you generated plugin folder. If this checks, open you android studio and select the option to open a android studio project, selecting the android folder to fulfil this procedure. You can select this option on the initial screen, like showed on the next image.
With the project opened, if all went well you'll se your android studio showing a screen like this
Now, lets add the plugin files. To do this, right click the android java module and select the "Open Module settings" option, as shown on the next image.
With the following screen opened, we need to add a module here that contains our jar/aar dependencies. To do that, just click on the + sign that is showed above.
On the new module screen, if you scroll down there will be a "Import .JAR/.AAR package", like shown above.
After that, locate you aar package. The result will be the following.
Click finish and the next screen will appear. If not, hit the apply button in this same screen.
Since my module has a dependency, I'll repeat this part of the tutorial.
Next, we need to add our recently added modules as dependencies of the android module. On the same screen, click on the dependencies option and on the plus sign of the "declared dependencies" pane.
The following screen will show. We need to select the 3rd option, since what we did early was adding a module.
Now, lets select our module. Its simple, just mark it and click ok. Since I have to, as said before, I'll check both of them.
If this step went well, you should have now you android module with one more dependency (or two in my case). The image bellow show that.
Hit apply and close this window. Gradle will rebuild your plugin project on the background and after that,since I know kotlin better, I'll convert my project to kotlin. If you wish, this can be done as shown on the next image, but is not mandatory.
With all the above done correctly, you can now import your lib on the TestPlugin.kt (or .java if you didnt use kotlin). For reference, the image bellow show the minimum implementation for my plugin.
In the plugin folder, we are done. Pack it using npm and install on you app.
Next, to the plugin works properly, we need to add its class on the MainActivity of the app that you'll be using it.
Now, to make it work, i'm not 100% sure that this is the correct way to do it, but since it works I do this way. The way I do is to add the plugin modules on the android module of the app via script. I think i am missing something on the gradle plugin implementation, but since it works.....
To do this, access, on your app, the android/settings.gradle file and append this:
Please note that depending on the changes that you do, the settings.gradle file will be rewritten. Do a script to keep the info always there or check it before build.
Thats it, please comment if you know another way to this next step or in any another if there is a better approach. And, if this answer is useful, please thumbs it up, since this implementation, when finished and working, made me cry a little (of happiness, of course).
I am having some issue with Android Studio which is kind Of annoying. Maybe you can help me out.
I did a git commit and push in a Github repo of mine which shows an example of how to work with Fragments.
I would like to build a new example in a new android studio project based on this repo, so i did a clone of this project in a new one with the wizard Android studio avails for this purpose.
It is not the first time that I do it and, meanwhile the clone works properly, Layout design tab for layout edition does not work.
I 've tried Clean and rebuild project but no luck :S
I am working with targetSDKVersion 26 and minSDKVersion 25.
I 've solved it mySelf. If someone encounters with this same problem, i will explain what i did.
I checked out the event Log and saw:
Error Loading Project: Cannot load module <PreviousProjectName>
If you expand the details, you may see a link for delete the old module. Click it.
Then i opened the build.gradle for the module app and changed the applicationID which was the same as the old project. Then I saved my build.gradle for the module and resynced my project:
After syncing and indexing and building... etc, the layout editor started working as usual. ;D
I'm using joda time (version 2.8.2) library in my project and everything works fine, but I'd like to use the specialized version for Android, as explained here: dlew/joda-time-android
While it was easy to add the joda time jar to Android Studio and adding the dependencies to the project, I didn't understand what to do in this case.
What do I have to download, where to put it and how to configure it.
Is there someone who did it and can write a step by step guide?
Thanks
Message update: I don't know why the question got two downvotes. I researched on Internet before posting the question. I also tried to contact the developer who posted the library on github. I didn't find an answer and it doesn't seem to be a stupid question, because I'm not getting tons of answers. I know I'm not an expert and for this reason I'm askingfor help, but before doing this, I always try to find a solution by myself. Thanks
Add this to the build.gradle file of your app:
dependencies
{
compile 'joda-time:joda-time:2.9.4'
}
In Android Studio Choose File>Project Structure. Then click dependencies tab in project structure. Click the + symbol (upper right corner) and choose library depencendy and type net.danlew in search bar. Click on net.danlew:android.joda:2.9.9 (current version as of today) if not already highlighted and then choose OK.
Ok, i've wasted an hour trying to figure it out, even though it's something really simple.
I've downloaded some code from github. I'd like to use this in my android application. How do I go about adding it? It's not a jar file, and i tried drag dropping it and linking the files, and it didn't work. Importing and refreshing / cleaning the project didn't work.
I'm not sure where I'm going wrong. Any help is greatly appreciated!
If this is a project you want to import in eclipse, right click on eclipse left pane (the project list), import, android project from files, select the repository folder.
If this is a library you want to use in you app, there is another step : go to the properties of your project, android tab and in the library section click on add, then select the library project.
By design, android code that contains layout resources (for example ActionBar Sherlock) can not be embedded in a jar. So you have to use it as a library project. It is very convenient though, since it allows you to look at or modify the library code very quickly.
You may also need to let Eclipse know that your library project is a library and not an app. To do so, in the same Properties/Android screen you just have to check the "is a library" checkbox.
Reference on that topic : official documentation
In Eclipse:
File->New->Other->"Android Project from exiting Code"
I've created library project in IDEA with common helpers, which I use in my android applications.
Then I've created android application and included in it my library project like this tutorial said.
Everything seemed okay, code autocomplete worked fine, IDEA recognize that library and all classes and methods in it.
But then I compiled application and saw error "'org.my.helperlibrary' does not exist". However as I said IDEA acts like everything okay before making/launching project.
Here is similar question, but answer is trivial, of course my library has checked "Is Library Project" option but I still can not launch my application which use my library.
Updated:
I've just saw an error: "UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/my/helperlibrary/Helper;" when I removed all usages of library in my android application. So it's just included in my app and not used.
It turned out that I should not add dependency manually in that window
I rather should add new module in my Project window at the left
Then I should choose iml file in the root folder of android library project I want to use
Then I pressed finish and from that point I had two modules in my project
After that when using classes I can press Alt+Enter on any class from SampleLibrary and tell IDEA to add module dependency
Then I could see that IDEA made all I need without me. I can now use SampleLibrary from SampleApplication!
Try to select library project, then click Build -> Compile <your library project name>.
Then back to you project which use this library and click Build -> Rebuild Project.
After that try to run project again.
Hope it helps.