【问题标题】:Importing GraphStream library in Android Studio在 Android Studio 中导入 GraphStream 库
【发布时间】:2018-11-15 07:17:07
【问题描述】:

我已经导入了 gs-ui-android 和 gs-core-2.0-alpha 模块,它们也反映在 settings.gradle 中。也将这些包含在 gradle app 模块中

implementation files(':gs-ui-android')
implementation files(':gs-core-2.0-alpha')

还包括导入语句

 import org.graphstream.graph.*;
    import org.graphstream.graph.implementations.*;

我仍然在这段代码中遇到错误

错误:包 org.graphstream.graph 不存在错误:包 org.graphstream.graph.implementations 不存在错误:不能 查找符号类 SingleGraph 错误:不兼容的类型:字符串不能 转换为节点报错:找不到符号类查看器

代码示例:

Graph graph1 = new SingleGraph("I can see dead pixels");
    graph1.addNode("A" );
    graph1.addNode("B" );
    graph1.addNode("C" );
    graph1.addEdge("AB", "A", "B");
    graph1.addEdge("BC", "B", "C");
    graph1.addEdge("CA", "C", "A");
    Viewer viewer = graph1.display();

Build.gradle(应用模块):

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.0.1'
    implementation 'io.particle:devicesetup:0.4.9'
    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'
    implementation 'com.github.john990:WaveView:v0.9'
    implementation 'org.giwi:android-network-graph:0.0.1'
    // implementation 'guru.nidi:graphviz-java:0.2.3'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
    api 'com.github.graphstream:gs-ui-android:2.0-alpha'
    api 'com.github.graphstream:gs-core:2.0-alpha'
//    implementation files(':gs-ui-android')
//    implementation files(':gs-core-2.0-alpha')

}
repositories {
    mavenCentral()
}

【问题讨论】:

    标签: java android graphstream


    【解决方案1】:

    可以使用jitpack导入github项目

    allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }
    

    然后你可以把链接放到想要的版本

    dependencies {
        api 'com.github.graphstream:gs-ui-android:2.0-alpha'
        api 'com.github.graphstream:gs-core:2.0-alpha'
    }
    

    这里你可以看到一个例子

    https://github.com/graphstream/gs-ui-android-test

    【讨论】:

    • 我已经包含了这些...仍然没有解决问题
    • 确认您使用的是相同版本的 gs-core 和 gs-android。你能运行这个例子吗?
    • 是的,我使用的是相同版本的两者仍然出现错误
    • 您可以编辑您的帖子以显示您的 build.gradle 已修改吗?
    • 我无法重现该问题。确保项目的最低 SDK 版本为 26,源/目标兼容性为 1.8。清理/重建,如果仍然不起作用,请尝试运行我给你的示例项目。
    猜你喜欢
    • 2015-07-11
    • 2020-11-04
    • 2016-01-19
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 2014-01-31
    • 2018-12-26
    • 2023-04-02
    相关资源
    最近更新 更多