How to import dropbox Chooser SDK in Android Studio? - android

https://www.dropbox.com/developers/dropins/chooser/android
I am trying to use the android chooser in Android Studio but I not sure how to import it to my project and user it. I am using Android Studio, not Eclipse Android Studio if that has any relevance. I just have no idea how to being the unzipped file into use in my project.

It's more complex than it ought to be, but this procedure worked for more than just the Dropbox SDK.
Unzip the Dropbox Chooser SDK somewhere
Open your project in Android Studio
Create a new sub-directory "libraries" (right-click -> new -> directory)
Create a new module in the libraries directory (right-click -> new -> module)
In the "New Module" window, from "More Modules" select "Android Library"
Click Next
Edit "Library name" to "dropbox-chooser"
Edit module name to "dropbox-chooser"
Edit package name to "com.dropbox.chooser.android"
Click next until done
Navigate to "libraries/dropbox-chooser/src/main"
Delete everything within the "java" and "res" directories, but do not remove the directories
Navigate to the directory where you have unzipped the SDK
Copy everything in the "src" directory to the "java" directory of the new module
Replace the "res" directory in the new module, with the one from the SDK
Do the same with AndroidManifest.xml
Now, to reference the library in your main project:
Open/Create "settings.gradle" in your main project dir
Add include 'libraries:dropbox-chooser' to the file
In build.gradle, withing the dependencies section add compile project(':libraries:dropbox-chooser')
This should do the trick.
Sync, build, and all should be good.

The Dropbox developers page now includes documentation on how to use the Chooser SDK with Android Studio.
Basically, you create a module from the SDK, and then you add it as a dependency to your project.
Detailed steps are described here: https://www.dropbox.com/developers/dropins/chooser/android

Related

Editing external libraries in Android Studio

I am using an image carousel library that I snagged off of github, but there are a few things I would like to change in the code. I have imported it using the compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+' command. Is that code available for me to edit somehow? Or is it downloaded from github every time I run my code?
For this you need to import it as lib and modify as you like:
To import the library to Android Studio, there are two methods that can work.
Method 1:
Open your project in Android Studio
Download the library (using Git, or a zip archive to unzip)
Create a folder "subProject" in your project
Copy and paste the FreemiumLibrary folder to your subProject folder
On the root of your project directory create/modify the settings.gradle file. It should contain something like the following:
include 'MyApp', ':subProject:FreemiumLibrary'
gradle clean & build/close the project and reopen/re-import it.
Edit your project's build.gradle to add this in the "dependencies" section:
dependencies {
//...
compile project(':subProject:FreemiumLibrary')
}
Edit your App Activities to extend AdsFragmentActivity instead of Activity.
Edit the library if you want to use it with ActionBarCompat
Method 2:
Open your project in Android Studio
Download the library (using Git, or a zip archive to unzip)
Go to File > New > Import-Module and import the library as a module
Right-click your app in project view and select "Open Module Settings"
Click the "Dependencies" tab and then the '+' button
Select "Module Dependency"
Select "Freemium Library" (not Freemium Library Project)
Modify your App Activities to extend AdsFragmentActivity instead of Activity.
Modify the library if you want to use it with ActionBarCompat
I solved this way. Fork library project. Then clone it (In Android Studio, File -> New -> Project from Version Control -> put the link of your repository that you forked and open it). Edit it and commit it to your master branch. Then push it to your master branch. And finally find snapshot version of that library. For example if you use JitPack. Go to jitpack.io website and search for your repository (forked version with your username). And there go to commits section and get latest version that you committed. And use that library dependency in your project instead of original repo.
My approach was similar to #Shailendra Madda's with some minor differences.
At first I downloaded/cloned the project in my PC. Let's say the library's name is 'VideoPlayer'.
I ensured that the module level gradle of VideoPlayer did not contain applicationId. I also ensured that it contained
plugins {
id 'com.android.library'
}
instead of
plugins {
id 'com.android.application'
}
Now the library is ready for import.
In order to import this library into my project, I went to File -> New -> Import Module.
From there, I selected the directory of VideoPlayer. The VideoPlayer project that I downloaded had four modules. In cases like this you can simply select the modules you want to import. I selected the module named core and clicked finish. [Note: instead of selecting VideoPlayer folder from the explorer, you can also select the 'core' folder].
After importing the module, go to File -> Project Structure (or Ctrl+Alt+Shift+S) and select dependencies. From modules section, select app (here, app is the name of my project's module) and then select the + icon in 'declared dependencies' section and select Module Dependency. From the new window, select the module you wish to add as dependency (in my case, it is 'core').
After you click Apply and/or OK, android studio will modify relevant gradle files, so you don't have to worrry about it. And the project will be added as a dependency in your project.
Check this page to learn more: https://developer.android.com/studio/projects/android-library

Rename root module in android studio

How to rename root module in android studio? I have tried (right click the module then click refactor then click rename) but I got warning "can't rename root module"
I pressed Ctrl+Shift+F to search my current root module name and found the name to be in the settings.gradle file as rootProject.name=.... I renamed it and synced the project (File -> Sync Project with Gradle Files) and the root module name was updated.
In root of your project
open setting.gradle and change
rootProject.name='YOUR NEW NAME'
then close and restart android studio
Close the project. (File > Close)
Rename the root folder of the project.
At the welcome screen "Open an existing Android Studio project" and provide the new path.
On your link that's the second answer or see also here.
This is tested for a pure Java projects (without any C/C++ code):
close the project and make a copy of the folder containing it
rename the new copied folder to reflect new project name
delete all *.iml files
reopen the project: Android Studio will resync Gradle, rebuild iml files
review the modules.xml file to remove reference to old project name
new project renamed works exactly as previous one: you can run the app without completely reinstalling it (all previous app data/settings/cache will be preserved)
Video tutorial: https://youtu.be/7aQjiae2doU
Refactor the name to com.example.[NewFileName] in path:
app>java>com.example.[OldFileName]
Go to strings.xml and change code to <string name="app_name”>[NewFileName]</string> in path:
app>res>values>strings.xml
Go to build.gradle (Module: app) and change code to applicationId "com.example.[NewFileName]” in path:
Gradle Scripts>build.gradle (Module: app)
Go to settings.gradle (Project Settings) and change code to rootProject.name='[NewFileName]' in path:
Gradle Scripts>build.gradle (Project Settings)
Press Sync now prompt
Rename your folder to [NewFileName] outside Android Studio
Reopen your project and rebuild project in path:
Build>Rebuild Project
In your Project pane, click on the little gear icon ( setting icon at the right top)
Uncheck / De-select the Compact Empty Middle Packages option
Your package directory will now be broken up in individual directories
Individually select each directory you want to rename, and:
Right-click it
Select Refactor
Click on Rename
In the Pop-up dialog, click on Rename Package instead of Rename Directory
Enter the new name and hit Refactor
Allow a minute to let Android Studio update all changes
Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All

Installing Vuforia in Android Studio

Can anyone give me some instructions of how I'm supposed to install Vuforia in Android Studio? I'm making a new app and I need to use augmented reality with Vuforia. Hope you can help me!
Thanks a lot!
You need to follow following Steps:
Read our Getting Started Guide for instructions on setting up the
Java SDK, Android SDK and NDK:
https://developer.vuforia.com/downloads/sdk
Make sure you have installed the latest version available of Android
Studio from:
http://developer.android.com/sdk/index.html
Use the Android SDK Manager (from within Android Studio) to get the
latest Android SDK and Android Platform and Build tools
Launch Android Studio
Select File - > Import Project ... and browse to the root directory
of the sample Vuforia project you want to open
Proceed in the Import Wizard dialog (click Next, Next) until you
reach a page with this message:
"Alternatively, you can fill in the actual path map in the table below":
click to edit
enter the actual path to the Vuforia.jar library (which is located under your vuforia_install_dir/build/java/vuforia)
In the Project view, right-click on the Project and expand the view
hierarchy so to locate the Vuforia.jar under app > src > main
right-click on Vuforia.jar to open the context menu
click on the "Add as library..." option in the context menu
Alternatively, if you cannot locate the Vuforia.jar in your project
hierarchy:
right-click on the Project and select, "Open Module Settings"
select "App"
then select the "Dependencies" tab
Click on the "+" button to Add a File Dependency and browse to the
Vuforia.jar file
Create a folder called "jniLibs" under the "app/src/main" folder under your Android Studio project directory
Copy the "armeabi-v7a" folder (including the libVuforia.so file
located inside it) from the "vuforia_install_dir/build/lib" to the
"app/src/main/jniLibs" folder
the resulting directory structure under your project root should be:
/app
/src
/main
/jniLibs
/armeabi-v7a
/**libVuforia.so**
If your project includes a "jni" folder, move it to a location
outside of your project (otherwise Android Studio may attempt to
compile the sources in that folder and may fail)
Clean and rebuild the project
Run the app on your device
Best Luck :)
answer from here and work for me:
(Seems like the project needs access to the Vuforia.jar file and can't access it outside of the sample folder(?))
So,
copy the Vuforia.jar file from the folder \vuforia-sdk-android-x-x-x\build\java\vuforia to a folder in the sample project, e.g. to \samples\app\libs
(it's important it's in the "\app" path, so you can find it in the next step)
in Android SDK hit F4 (or right click on the app folder in the project structure and click on "Open Module Settings".
Select the tab "dependencies", click on the "+" to add a dependency and select "2 File dependency".
Now select the above path and file ((\samples\app) \libs\Vuforia.jar) and the project will run just fine...
Good luck.

Import an eclipse android project with version control system into Android Studio

I am trying to import an eclipse project with version control system into Android Studio.
Support for direct eclipse project import was added in Android-Studio version "0.5.5" where we don't need to export project first from eclipse to import it into Android-Studio.
I have an eclipse Android Project which I am trying to import into Android Studio.
Import is successful but imported project no more has version control.
Edit:- More detail
Suppose I have following Directory Structure
Project ----
|---------- .git/
|----------- MyApp
|------------MyApp_imported
During project import, I point Android Studio to Project Directory "MyApp", It copies all files in my project "MyApp" to new directory "MyApp_Imported". But imported project doesn't have version control enabled.
Now I am not sure how to proceed further.
How should I tell Android Studio to use old repository for imported project.
A step by step guide to do this will be very helpful .
Here is text from Android Tools Project Site
Project
- Importing modules should now work properly. You can import existing Eclipse
ADT projects as well as Gradle modules into an existing Gradle project;
it will copy in the sources as is done for full project import, as well as
handle dependencies transitively. Import modules either from the project structure dialog or the File | Import Module action.
- New project structure dialog implementation: Should be faster, includes
Gradle sync notification, should only perform a Gradle sync at the end
when necessary, and won't list invalid IntelliJ module warnings as before.
This is actively being worked on and the individual editors
(for flavors, build types, signing configurations etc) will be improved
in upcoming builds.
Here is the step by step solution to do it.
Open Android Studio -> Import Project-> Select your project directory. (In above case "MyApp")
Remember Select the directory which contains Manifest file otherwise new "direct import wizard" doesn't
get triggered and android studio uses old import wizard.
Android Studio will create a copy of your project "MyApp_imported" with new directory structure.
Copy your existing ".git" directory inside "MyApp_imported"
Android Studio -> VCS -> Enable version control
This will make Android Studio use your existing repository for imported project. Though imported project has
different directory structure but git handles them pretty well.
You might want to also call git add . and git add -u in the root folder of the imported project to make sure all new files are added and existing file moves are detected by git.
Android Studio -> Changes
Review all files and commit. Git will automatically handle new directory structure and file history etc will not be lost.
Now you can share it on github/Bitbucket by
VCS-> Share it on GitHUb
Note:- For bitbucket you will have to install "Bitbucket plugin" for Android Studio.
Couple of months ago I got my job as android developer.The first problem i had faced were my collegues who using Eclipse.I was allowed to use Android studio if I will not make any changes to existing project structure.After 3-4 attemps I finally found a decision.Here is steps to open Eclipse git project without migrating to Gradle and without changing project structure.
Clone git repository of project
Add /gen and /.idea to .gitignore
Open any of already created Android Studio projects.
File -> Open -> Choose path root project folder(with src and res inside)
Doble-click project to open project structure
Select root project folder -> F4
Project -> Project SDK -> Android API XX Platform && Project language level -> Override in interfaces
Modules -> Sources tab. Mark src as Sources && res as Resources.
Modules -> Paths tab. Use module compile output path.Create folders output and output_test inside gen folder (create gen if folder not exist yet).Output paths should look like C:\Users\User\project_rep\project\gen\output
Modules -> Dependencies tab. Click "+" -> Jars or directories.Select all .jar libraries which are using by your project.(Android Studio can pretend like its added only one jar but thats not true)
Facets -> "+" -> Android
Facets -> Structure tab -> Reset to defaults.
Close Project Structure window.
Run -> Edit configurations -> Android Application -> Module -> Select your module.Target device -> Show chooser dialog.
Edit configurations -> Before launch -> remove Gragle aware make, add Make.
Finally, after all of those steps you are able to hit Run button.Enjoy!
The import process does not make this easy. But here's something to try:
Let Android Studio do what it wants to do. It creates a file in the root of the new copy of the project which shows what was moved where.
Make a fresh (scratch) copy of the original git repository. Use "git mv" commands to duplicate the directory structure changes which Android Studio made. Commit the changes.
Copy the resulting .git directory into the project made by Android Studio. Use "git status" there to see how the result of the import process differs from what you did in your scratch copy of the project. At this point you might just choose to commit the remaining differences right there.

Using Android Studio with Vuforia [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Here is how I run a Vuforia Sample on Android Studio on Window 8
Download, extract sample, remove files .project and project.properties
On Android Studio : Import project, next, next ...
Download & install android NDK http://developer.android.com/tools/sdk/ndk/index.html
Download & install cygwin http://cygwin.com/
Edit the file jni/Android.mk
LOCAL_SRC_FILES = C:/Vuforia-sdk/build/lib/$(TARGET_ARCH_ABI)/libQCAR.so
LOCAL_EXPORT_C_INCLUDES := C:/Vuforia-sdk/build/include
where Vuforia-sdk is your vuforia sdk
Open cmd in your project folder and do "ndk-build"
In android studio, click on project structure, modules, "YourModuleName", Dependencies, add jars, select the correct path to vuforia sdk for me it was :
C:\Vuforia-sdk\build\java\QCAR\QCAR.jar
build & run your project in Android Studio
Have fun!
*Don't forget the PATH variable for the ndk & cygwin
Read our Getting Started Guide for instructions on setting up the Java SDK, Android SDK and NDK:
https://developer.vuforia.com/resources/dev-guide/getting-started-android-native-sdk
Make sure you have installed the latest version available of Android Studio from:
http://developer.android.com/sdk/index.html
Use the Android SDK Manager (from within Android Studio) to get the latest Android SDK and Android Platform and Build tools
Launch Android Studio
Select File - > Import Project ... and browse to the root directory of the
sample Vuforia project you want to open
Proceed in the Import Wizard dialog (click Next, Next) until you reach a page with this message:
"Alternatively, you can fill in the actual path map in the table below":
click to edit
enter the actual path to the Vuforia.jar library (which is located under your vuforia_install_dir/build/java/vuforia)
In the Project view, right-click on the Project and expand the view hierarchy so to locate the Vuforia.jar under app > src > main
right-click on Vuforia.jar to open the context menu
click on the "Add as library..." option in the context menu
Alternatively, if you cannot locate the Vuforia.jar in your project hierarchy:
right-click on the Project and select "Open Module Settings"
select "App"
then select the "Dependencies" tab
Click on the "+" button to Add a File Dependency and browse to the Vuforia.jar file
Create a folder called "jniLibs" under the "app/src/main" folder under your Android Studio project directory
Copy the "armeabi-v7a" folder (including the libVuforia.so file located inside it) from the "vuforia_install_dir/build/lib" to the "app/src/main/jniLibs" folder
the resulting directory structure under your project root should be:
/app
/src
/main
/jniLibs
/armeabi-v7a
libVuforia.so
Clean and rebuild the project
Run the app on your device
Try this,
Exporting Eclipse Project with vuforia into Android Studio, which worked for me.
Below are the steps which i followed to the project work fine in Android Studio.
Export the Eclipse project from Eclipse as a Gradle project.
Go to the welcome to android studio window in android studio.
Click on Import Non android studio project.
Locate the project that you exported from eclipse, expand it and select the build.gradle file and click ok.
Copy the vuforia.jar file from the vuforia sdk.
Right click on the project in android studio and click on Show in Explorer option.
Locate the libs folder and paste the copied vuforia.jar file.
Make a folder lib ( NOTE: it is not libs) in the same structure as APK file.
Make another folder armeabi inside lib folder.
Copy .so files and paste it inside armeabi folder. and zip the lib folder into lib.zip
Rename the lib.zip to armeabi.jar
Include the armeabi.jar inside libs folder.
Then clean build and run the project.

Categories

Resources