dialogflow / dialogflow-android-client

Android SDK for Dialogflow
https://dialogflow.com
Apache License 2.0
575 stars 270 forks source link

unable to import ai.api.model in my andorid studio #41

Open udittakwani opened 7 years ago

udittakwani commented 7 years ago

it is continuously showing cannot resolve symbol model and same error is shown forsupportedlanguages plz help me with this i am stuck picture2

ghost commented 7 years ago

Same problem here, please help!

AniFichadia commented 7 years ago

Try Re-syncing gradle or invalidating your caches and restarting Android Studio. If that doesn't work, please post your build.gradle files (module and project). You may not have the correct repositories setup in your project build.gradle (the API AI libs are published on maven central not jcenter) file or there's some other dependency resolution issue

Aashit-Sharma commented 7 years ago

did you add the dependency : compile 'ai.api:sdk:2.0.4@aar' ? if not , do so in your app-level build.gradle that should solve it

zuxie commented 7 years ago

can someone give more insights on this issue? I've tried adding 'ai.api:sdk:2.0.4@aar' dependency as well as using maven central. This is my project build.gradle and app build.gradle

screen shot 2017-06-21 at 8 02 33 pm screen shot 2017-06-21 at 8 02 24 pm
AniFichadia commented 7 years ago

@zuxie Looks like you're also missing some of the other (transitive) dependencies, like the API AI models lib. Check out the readme.md file on this repo: https://github.com/api-ai/apiai-android-client/blob/master/README.md

You need to also add

compile 'ai.api:libai:1.4.8'
compile 'com.google.code.gson:gson:2.3.1'
compile 'commons-io:commons-io:2.4'

You should be fine with newer versions of gson (eg. gson v 2.7)

Correct me if I'm wrong, but I think when you have an aar dependency, it doesn't include the transitive dependencies. You have to explicitly include them or force the dependency to be transitive (as long as there's a pom file or similar also published).

zuxie commented 7 years ago

@AniFichadia Thank you so much! That fixed the issue. For those who have the same problem, make sure to follow the format shown in the example, make sure to include thepackagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'LICENSE.txt' } part.

Now the app crashes when I click on the listen button, displaying java.lang.NoClassDefFoundError. Does anyone have a fix for this issue?

screen shot 2017-06-21 at 11 18 27 pm
imanpakii commented 7 years ago

Hello I'm trying to add dependency of ai.api to https://github.com/Kitt-AI/snowboy project. when I try to add all dependency I get Failed to resolve :ai.api:libai-base:1.4.8 and other dependency
this is my build.gradle

apply plugin: 'com.android.application'
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}
android {
    signingConfigs {
    }
    compileSdkVersion 25'
    buildToolsVersion '25.0.0'
    compileOptions.encoding = 'ISO-8859-1'
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    buildTypes {
        release {
        }
    }
    defaultConfig {
    }
    productFlavors {
    }
    externalNativeBuild {
        ndkBuild {
            path '../../../../../../Tools/example-wiringPi/jni/Android.mk'
        }
    }
}

dependencies {
    compile 'ai.api:libai-base:1.4.8'
}

please help thank you

imanpakii commented 7 years ago

for somebody who has the same issue I had: I fix this issue by adding this:

repositories {
    mavenCentral()
}

and later on added this:

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'LICENSE.txt'
    }

for this issue:

Error:Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
    File1: /Users/imanyazdansepas/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.2/d7ef6ad7ff0711dd12fe409d62d72d6ed14516e0/log4j-api-2.2.jar
    File2: /Users/imanyazdansepas/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar
folomeev commented 7 years ago

Please try to use new library version: 2.0.6 instead of 2.0.5

akhilreso commented 7 years ago

Please tell m how can i add api.ai sdk??tried to import ailib module in my project but gives an error Error:(5, 0) Could not get unknown property 'ANDROID_BUILD_SDK_VERSION' for project ':ailib' of type org.gradle.api.Project.

meetferoz commented 7 years ago

Hi, i did all the above but i still get Error:(8, 20) error: package ai.api.model does not exist what could be the issue?

here is my build.gradle (module app)

apply plugin: 'com.android.application'

android { compileSdkVersion 25 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.example.feroz.testapp1" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'LICENSE.txt' } }

repositories { mavenLocal() mavenCentral()

maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

}

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile 'ai.api:sdk:2.0.7@aar' compile 'com.google.code.gson:gson:2.8.1' compile 'commons-io:commons-io:20030203.000550' compile 'ai.api:libai-base:1.6.12' }

yyuripp commented 7 years ago

@meetferoz usa o compile 'ai.api:libai:1.6.12' ao invés do compile 'ai.api:libai-base:1.6.12'.

Pra mim funcionou.

diegodromer commented 7 years ago

vlw cara, apenas essa linha solucionou o problema. Tinha feito um monte de coisae nada solucionou. vlwwww!!!

balaji-purusothaman-2794 commented 6 years ago

Me too had the same. Please help to fix, i'm using android studio 3.0 and kotlin here is my build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android { compileSdkVersion 26 defaultConfig { applicationId "com.example.balajip.riya" minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'LICENSE.txt' } } repositories { mavenLocal() mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' compile 'ai.api:sdk:2.0.7@aar' compile 'com.google.code.gson:gson:2.8.2' compile 'commons-io:commons-io:2.4' compile 'ai.api:libai-base:1.6.12' }