在 Android Studio 中导入 GraphStream 库

Importing GraphStream library in Android Studio

我导入了 gs-ui-android 和 gs-core-2.0-alpha 模块,它们也反映在 settings.gradle 中。还包括在 gradle 应用程序模块

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

还包括导入语句

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

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

error: package org.graphstream.graph does not exist error: package org.graphstream.graph.implementations does not exist error: cannot find symbol class SingleGraph error: incompatible types: String cannot be converted to Node error: cannot find symbol class Viewer

代码示例:

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()
}

可以使用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