0

I created two sample project. Now i want to import one project into another second project. The process of importing project i followed is like-

new ->module->Import Gradle Project.

Then added module dependency

 implementation project(':secondapp');

But i am getting error like-

 Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :secondapp 
 Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :secondapp
 Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :secondapp
 Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :secondapp

So please tell me what's solution. I am using Android studio 3.0.

My actual scenario is like i have two projects and i want to merge both project into third empty project so that i don't have to manage 2 application and according to condition i can launch any one Activity of both projects. for example-

if(firstProject){
     startActivity(new Intent(thirdprojectActivty.this,firstprojectlaunchactivity.class));
}else{
     startActivity(new Intent(thirdprojectActivty.this,secondprojectlaunchactivity.class));
}

So tell me this scenario possible by importing project as module or there is any other solution for this scenario?

Dharmishtha
  • 1,313
  • 10
  • 21
shyam002
  • 237
  • 1
  • 5
  • 19
  • Possible duplicate of [Import module to gradle project on android studio 0.4.0v](https://stackoverflow.com/questions/20770118/import-module-to-gradle-project-on-android-studio-0-4-0v) – Dipali Shah Dec 15 '17 at 10:26

2 Answers2

0

You can do this thing by import that 2 project in 3rd one as module and make changes in build.gradle file for use that as library .

compile project(':moduleaName')

To add as Library follow below step:

File -> Project Structure -> Dependencies -> click on + icon -> select Module Dependnacies then select module -> click ok -> again click ok

Hope this Help.

Dharmishtha
  • 1,313
  • 10
  • 21
0

As suggested by Imene Noomenefound two type of solutions :

Solution with the old g‌​radle-3.3 :

  1. As first and temporary solution to make the project run with android studio 3.0 , maintain the old config of my previous of Android Studio 2.3 distributionUrl=https://services.gradle.org/distributions/g‌​radle-3.3-all.zip , compileSdkVersion 25 and buildToolsVersion "25.0.3" and classpath 'com.android.tools.build:gradle:2.3.3*

Solution with the new g‌​radle-4.1 :

  1. To work with the new features of gradle 4.1 and the classpath 'com.android.tools.build:gradle:3.0.0' , followed this link https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html . So, Those are my implementations : In the file gradle-wrapper.properties :

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip

In the file build.gradle of the project :

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        //classpath 'me.tatarka:gradle-retrolambda:3.3.1' remove this line
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
In the file build.gradle of the app :

apply plugin: 'com.android.application'
//apply plugin: 'me.tatarka.retrolambda' remove this line

repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
    jcenter()
    mavenCentral()
    maven { url "https://jitpack.io" }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.imennmn.myprojectid"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        /**
         * Enabling multidex support.
         */
        multiDexEnabled true
        missingDimensionStrategy 'minApi' , 'minApi24'

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }

        dexOptions {
            javaMaxHeapSize "4g"
            preDexLibraries = false
        }

    }
    buildTypes {
        release {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }

    /**
     * Solve the problem when using multiple free source libs
     * NOTICE or LICENSE files cause duplicates
     */
    packagingOptions {

    }


}

dependencies {
   //your dependecies

}

In the build.gradle of the library animator upgrade targetSdkVersion to 26 :

apply plugin: 'com.android.library'

android {
  compileSdkVersion 26
  buildToolsVersion '26.0.2'

  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
  }
}

dependencies {
  implementation "com.android.support:support-compat:26.0.2"
  implementation "com.android.support:support-core-ui:26.0.2"
  implementation "com.android.support:recyclerview-v7:26.0.2}
Dipali Shah
  • 3,742
  • 32
  • 47