-
Notifications
You must be signed in to change notification settings - Fork 398
Description
Hello when i try it under Android i get such a error. Can you help ?
Exception Log:
2018-11-01 11:31:27.416 17631-17631/net.maksimum.jsonschemevalidator E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.maksimum.jsonschemevalidator, PID: 17631
java.lang.ExceptionInInitializerError
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:65)
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:44)
at com.github.fge.jsonschema.SchemaVersion.values(SchemaVersion.java:39)
at com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder.(LoadingConfigurationBuilder.java:119)
at com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration.byDefault(LoadingConfiguration.java:151)
at com.github.fge.jsonschema.main.JsonSchemaFactoryBuilder.(JsonSchemaFactoryBuilder.java:67)
at com.github.fge.jsonschema.main.JsonSchemaFactory.newBuilder(JsonSchemaFactory.java:123)
at com.github.fge.jsonschema.main.JsonSchemaFactory.byDefault(JsonSchemaFactory.java:113)
at net.maksimum.jsonschemevalidator.MainActivity$1.onClick(MainActivity.java:60)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24708)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6565)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.io.IOException: resource /draftv4/schema not found
at com.github.fge.jackson.JsonLoader.fromResource(JsonLoader.java:91)
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:63)
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:44)
at com.github.fge.jsonschema.SchemaVersion.values(SchemaVersion.java:39)
at com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder.(LoadingConfigurationBuilder.java:119)
at com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration.byDefault(LoadingConfiguration.java:151)
at com.github.fge.jsonschema.main.JsonSchemaFactoryBuilder.(JsonSchemaFactoryBuilder.java:67)
at com.github.fge.jsonschema.main.JsonSchemaFactory.newBuilder(JsonSchemaFactory.java:123)
at com.github.fge.jsonschema.main.JsonSchemaFactory.byDefault(JsonSchemaFactory.java:113)
at net.maksimum.jsonschemevalidator.MainActivity$1.onClick(MainActivity.java:60)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24708)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6565)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
My Gradle File:
apply plugin: 'com.android.application'
repositories {
//maven { url 'https://jitpack.io'}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "net.maksimum.jsonschemevalidator"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/ASL-2.0.txt'
exclude 'META-INF/LGPL-3.0.txt'
exclude 'draftv4/schema'
exclude 'draftv3/schema'
}
/*
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
*/
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
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'
implementation 'com.android.support:design:28.0.0'
implementation 'commons-io:commons-io:2.5'
implementation (group: "com.github.java-json-tools", name: "json-schema-validator", version: "2.2.10");
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'
}
My MainActivity
package net.maksimum.jsonschemevalidator;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.examples.Utils;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
try {
Log.i("JSL","Start");
final JsonNode fstabSchema = Utils.loadResource("/fstab.json");
final JsonNode good = Utils.loadResource("/fstab-good.json");
final JsonNode bad = Utils.loadResource("/fstab-bad.json");
final JsonNode bad2 = Utils.loadResource("/fstab-bad2.json");
//Log.i("JSL",fstabSchema.toString());
//Log.i("JSL",good.toString());
//Log.i("JSL",bad.toString());
//Log.i("JSL",bad2.toString());
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
final JsonSchema schema = factory.getJsonSchema(fstabSchema);
Log.i("JSL","End");
} catch (IOException e) {
e.printStackTrace();
} catch (ProcessingException e) {
e.printStackTrace();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}