glob3mobile / g3m

The multiplatform advanced visualization framework
http://www.glob3mobile.com/
Other
116 stars 56 forks source link

Migration to Android Studio #137

Closed octavianiLocator closed 8 years ago

octavianiLocator commented 8 years ago

Hi and thank you for your work and dedication to this framework!

Since Support for the Android Developer Tools (ADT) in Eclipse is ending, is it possible to include a tutorial describing how import G3M into an Android Studio project? All my attempts fail when adding the G3MShared as a module in my Android Studio project.

Thank you in advance.

mdelacalle commented 8 years ago

Hi Thanks for using Glob3 Mobile.

We are part of Eclipse foundation and we are very happy with our development IDE. We know that this support is ending but currently we have no plans to do anything with this issue.

We invite you or any other user of the library to star the migration (I'm sure that is a well documented thing) and document it and share with the other interested used.

We accept any kind of collaboration and we try to help you in all you need.

Another possible solution for works outside our roadmap is hire us and we can do and document the migration for you.

Thanks!

octavianiLocator commented 8 years ago

I have just started contemplating on this project that involves G3M, so I can't really say there is a migration to be done. It is a leisure activity for me to learn to program Android apps.

Nonetheless, I would be very grateful if you could point me in the direction to create a simple application in Android Studio that includes the G3MAndroidSDK and G3MSharedSDK projects and I will document those steps and share them.

Do we have a deal?

DiegoGomezDeck commented 8 years ago

Hello @octavianiLocator

I'm glad you're contemplating using G3M on your project.

Sadly, we can't help you much here as we don't have too much experience using AndroidStudio...

Anyway I can tell you, we spent some (ok, actually 'less' than some) time in the past and I remember we were able to convert the project just using the "import eclipse project" feature of AndroidStudio and it worked just fine.

Please give it a try to this option, and let us know.

akosmaroy commented 8 years ago

we're using g3m in android studio / gradle. here is the portion of our build.gradle file that makes it work. as you see, we've put g3m into a lib/external/g3m directory (as a git submodule)

project(':lib:external:g3m:Commons:G3MSharedSDK') {
    apply plugin: 'java'

    sourceCompatibility = 1.6
    version = '1.0'

    sourceSets {
        main {
            java {
                srcDir 'src'
            }
        }
    }
}

project(':lib:external:g3m:Android:G3MAndroidSDK') {
    apply plugin: 'com.android.library'

    dependencies {
        compile files('libs/java_websocket.jar')
        compile project(':lib:external:g3m:Commons:G3MSharedSDK')
    }

    android {
        compileSdkVersion 15
        buildToolsVersion "21.1.2"

        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
        }
    }
}

project(':lib:external:g3m:WebGL:G3MWebGLSDK') {
    apply plugin: 'java'
    apply plugin: 'gwt'
    apply plugin: 'gwt-base'
    apply plugin: 'eclipse'

    repositories {
        maven {
            url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/'
        }
        mavenCentral()
    }

    dependencies {
        compile project(':lib:external:g3m:Commons:G3MSharedSDK')
    }

    gwt {
        gwtVersion='2.6.0'

        sourceSets {
            main {
                java {
                    srcDir 'src'
                }
            }
        }
    }
}
octavianiLocator commented 8 years ago

Thank you @DiegoGomezDeck and @akosmaroy for your suggestions and help.

I tried @DiegoGomezDeck 's method and this did not work for me. I started by creating an Android app project in Android Studio and the importing the G3MAndroidSDK and G3MSharedSDK projects as modules.

@akosmaroy can you please tell me whether you created an "lib\external" folder in "Project" or "external" folder in "Project\app\libs" folder? Did you manually copy the G3MAndroidSDK and G3MSharedSDK projects, or is there a setting to be made in Android Studio for putting them at the location?

akosmaroy commented 8 years ago

@octavianiLocator I'm not sure I understand your reference to various folders.

we have the following directory structure:

project root
|-- build.gradle
`-- lib
    `-- external
        `-- g3m

the gradle content I copied above is in the build.gradle file in the root directory

we're referencing g3m as a git submodule

octavianiLocator commented 8 years ago

Thank you again @akosmaroy, you answered one of the questions - about the structure of the project.

After I make a new Android App project in Studio, I create the "root/lib/external/g3m" path and then manually copy the required projects from the g3m framework. Finally, I modify the build.gradle file with the code that you provided. The error I receive suggests it can't find the project in "root/lib/external/g3m/Commons/G3MSharedSDK", although it is at that location.

Error:(14, 1) A problem occurred evaluating root project 'G3M_Test_AS'.

Project with path ':lib:external:g3m:Commons:G3MSharedSDK' could not be found in root project 'G3M_Test_AS'.

How do you reference g3m as a git submodule? Do I have to create a different type of project?

akosmaroy commented 8 years ago

@octavianiLocator indeed, I might have missed something. you maybe also have to create / modfile your settings.gradle file in the project root, to contain:

include 'lib:external:g3m:Commons:G3MSharedSDK'
include 'lib:external:g3m:Android:G3MAndroidSDK'
include 'lib:external:g3m:WebGL:G3MWebGLSDK'

you can read up on gradle multi-project builds here: https://docs.gradle.org/current/userguide/multi_project_builds.html

re 'git submodule' - it's just better than copying by hand, so that you maintain a reference to the original g3m git repository, read up more here: https://git-scm.com/book/en/v2/Git-Tools-Submodules

octavianiLocator commented 8 years ago

Great info @akosmaroy. I can now import g3m classes in my project. Nontheless, there is a final conflict when I build, given by the merger of the two AndroidManifest.xml files: the one in my project and the one in the G3MAndroidSDK project. It seems to be related to the appName label.

Thank you a lot for your help and tips. Wish you a great week ahead.

akosmaroy commented 8 years ago

in your AndroidManifest.xml, you need to add:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          ....
>

...

    <application
        ...
        tools:replace="android:label">
octavianiLocator commented 8 years ago

Thank you for your persistent help, @akosmaroy ! :+1: It works now. Wish you good luck in your endeavors.