我对数学公式和搜索很感兴趣我偶然发现了这个MathView,它满足了我对我的应用程序的需求...但是我无法使它工作,我确实按照步骤通过Maven导入存储依赖项,我遇到与此处Getting MathView to work in Android
相同的问题工具:
Android Studio 2.2
Windows 10 Pro x64
Gradle依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:24.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'io.github.kexanie.library:MathView:0.0.6'
testCompile 'junit:junit:4.12'
}
这是我的布局:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:auto="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.github.kexanie.library.MathView
android:id="@+id/formula_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
auto:text="When \\(a \\ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\)
and they are $$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$"
auto:engine="MathJax">
</io.github.kexanie.library.MathView>
</android.support.constraint.ConstraintLayout>
以下是完整错误:
java.lang.NoSuchMethodError: io.github.kexanie.library.MathView.getSettings()Landroid/webkit/WebSettings;
at io.github.kexanie.library.MathView.<init>(MathView.java:24)
at sun.reflect.GeneratedConstructorAccessor482.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$72(RenderTask.java:659)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
这个问题有解决方案吗?
我也知道MathJax和KaTeX,但我找不到有关如何在Android中集成的任何相关信息
提前致谢
答案 0 :(得分:0)
导入mathview中的模块。 打开文件 - &gt; new module-&gt; gradle,在这里你要从github文件夹导入mathview。
然后打开项目文件项目sturture =&gt;应用程序&gt;依赖项&gt;“+”&gt; mathview&gt;确定
然后在项目gradle中
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath "com.github.dcendents:android-maven-gradle-plugin:1.3"