我在安装库时遇到问题

时间:2019-05-05 20:17:44

标签: java android android-gradle shared-libraries

我正在尝试使用jlatemath库。
我已将.jar文件放在libs文件夹下, 这是我的礼物。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation files('libs/jlatexmath-android-0.1.0-sources.jar')
    implementation files('libs/jlatexmath-android-font-cyrillic-0.1.0-sources.jar')
    implementation files('libs/jlatexmath-android-font-greek-0.1.0-sources.jar')
}

我认为我不需要两者,但我只是为了确定而放置它们。

我尝试清理并重建项目。

没有runtask,构建就顺利完成了,
但是我的代码仍然没有从库中找到类,这意味着找不到类的自动导入。

这是我第一次使用图书馆,所以我可能错过了一些愚蠢的东西,但是如果有人可以让我知道它是什么,将不胜感激。

1 个答案:

答案 0 :(得分:0)

Follow these steps 我刚刚注意到的是,您正在尝试手动下载和添加依赖项。这是一个漫长而繁琐的过程!您可以粘贴并让android studio帮您完成。

对于您的情况,您需要在build.gradle中添加这些行

    implementation 'ru.noties:jlatexmath-android:0.1.0'

    // for Cyrillic symbols
    implementation 'ru.noties:jlatexmath-android-font-cyrillic:0.1.0'

并同步项目。不要忘记删除以前手动添加依赖项的所有行。

因此您在问题中的代码应如下所示

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


    //PASTE HERE DEPENDENCIES

    implementation 'ru.noties:jlatexmath-android:0.1.0'

    // for Cyrillic symbols
    implementation 'ru.noties:jlatexmath-android-font-cyrillic:0.1.0'
}

如果不能解决您的问题,请告诉我。

如果您喜欢视频教程,可以按照本教程了解如何在android studio here中添加依赖项。

相关问题