0 / 0 / 0
Регистрация: 02.09.2018
Сообщений: 1
|
|
|
|
FATAL EXCEPTION: main (
02.09.2018, 15:35. Показов 1376. Ответов 3
Пишу новостное приложение. Прога начинается с navigation drawer activity, в которое я запарсил через xml api новостей.
Прога еще имеет 2 фрагмента в шторке навигации.
Как только запускаю приложение - оно сразу крашится. Studio не подсвечивает ошибок в коде... прошу помощи! Дедлайн близко, а это мое тестовое на Juniora((
Вот код MainActivity
| Java | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
| package com.example.developer.nasibovtestcityguide;
import android.content.Context;
import android.os.AsyncTask;
import android.app.ProgressDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class ReadNews extends AsyncTask<Void,Void,Void> {
Context context;
String address = "https://www.go102.ru/api2/news";
ProgressDialog progressDialog;
ArrayList<FeedItem>feedItems;
RecyclerView recyclerView;
URL url;
public ReadNews(Context context, RecyclerView recyclerView){
this.recyclerView = recyclerView;
this.context = context;
progressDialog = new ProgressDialog(context);
progressDialog.setMessage("Загрузка...");
}
@Override
protected void onPreExecute() {
progressDialog.show();
super.onPreExecute();
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
progressDialog.dismiss();
MyAdapter adapter = new MyAdapter(context, feedItems);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(adapter);
}
@Override
protected Void doInBackground(Void... params) {
ProcessXml(Getdata());
return null;
}
private void ProcessXml(Document data) {
if (data != null) {
feedItems = new ArrayList<>();
Element root = data.getDocumentElement();
Node channel = root.getChildNodes().item(1);
NodeList items = channel.getChildNodes();
for (int i=0; i<items.getLength(); i++){
Node cureentchild = items.item(i);
if (cureentchild.getNodeName().equalsIgnoreCase("item")){
FeedItem item = new FeedItem();
NodeList itemchilds = cureentchild.getChildNodes();
for (int j=0; j<itemchilds.getLength(); j++){
Node cureent = itemchilds.item(j);
if (cureent.getNodeName().equalsIgnoreCase("name")){
item.setName(cureent.getTextContent());
}else if (cureent.getNodeName().equalsIgnoreCase("txt")){
item.setTxt(cureent.getTextContent());
}else if (cureent.getNodeName().equalsIgnoreCase("date_show_unix")){
item.setDate_show_unix(cureent.getTextContent());
}else if (cureent.getNodeName().equalsIgnoreCase("imgfull")){
String url = cureent.getAttributes().item(0).getTextContent();
item.setImgfull(url);
}
}
feedItems.add(item);
}
}
}
}
public Document Getdata() {
try {
url = new URL(address);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
InputStream inputStream = connection.getInputStream();
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document xmlDoc = builder.parse(inputStream);
return xmlDoc;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
} |
|
Вот мой манифест
| Java | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.developer.nasibovtestcityguide">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/news_launch"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> |
|
Вот что пишет в логе:
| Java | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| 09-02 11:00:02.597 7291-7291/com.example.developer.nasibovtestcityguide E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.developer.nasibovtestcityguide, PID: 7291
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.developer.nasibovtestcityguide/com.example.developer.nasibovtestcityguide.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
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: android.view.InflateException: Binary XML file line #11: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.RelativeLayout" on path: DexPathList[[zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/base.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_resources_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
09-02 11:00:02.610 7291-7291/com.example.developer.nasibovtestcityguide E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.developer.nasibovtestcityguide.MainActivity.onCreate(MainActivity.java:26)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
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)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.developer.nasibovtestcityguide-kMSTA8DN78AzgfL4CUUTug==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:353)
at dalvik.system.DexFile.<init>(DexFile.java:100)
at dalvik.system.DexFile.<init>(DexFile.java:74)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
at dalvik.system.DexPathList.<init>(DexPathList.java:157)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:676)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:709)
at android.app.LoadedApk.getResources(LoadedApk.java:936)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2242)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5672)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
... 6 more |
|
Добавлено через 9 минут
Ой туплю.. вот мой MainActivity :
| Java | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
| package com.example.developer.nasibovtestcityguide;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ReadNews readNews = new ReadNews(this, recyclerView);
readNews.execute();
recyclerView =(RecyclerView)findViewById(R.id.recyclerview);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.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);
}
private void displaySelectedScreen (int id) {
Fragment fragment = null;
switch (id) {
case R.id.nav_settings:
fragment = new Settings();
break;
case R.id.nav_program:
fragment = new About_program();
break;
}
if (fragment != null) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_main, fragment);
ft.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
displaySelectedScreen(id);
return true;
}
} |
|
0
|