Форум программистов, компьютерный форум, киберфорум
Программирование Android
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.71/7: Рейтинг темы: голосов - 7, средняя оценка - 4.71
0 / 0 / 0
Регистрация: 02.09.2018
Сообщений: 1

FATAL EXCEPTION: main (

02.09.2018, 15:35. Показов 1368. Ответов 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
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
02.09.2018, 15:35
Ответы с готовыми решениями:

FATAL EXCEPTION: main
добрый день, столкнулся с проблемой, когда выбивает подобную ошибку: 12-12 07:18:22.455: E/AndroidRuntime(1352): FATAL EXCEPTION: main...

FATAL EXCEPTION: main
Забавная у меня ситуация, вот создаю новый проект и он не хочет запускаться ни в какую, хотя ничего своего не добавляю в него ...

FATAL EXCEPTION: main
Я только начал проходить уроки по программированию на android и сразу же ошибка - unfortunately, MyProject has stopped. Я пытался добавить...

3
1570 / 1168 / 426
Регистрация: 08.05.2012
Сообщений: 5,219
02.09.2018, 23:05
Ошибка в разметке.

Не по теме:

Можешь не париться по поводу дедлайна

0
+1
345 / 178 / 53
Регистрация: 24.08.2010
Сообщений: 1,028
03.09.2018, 04:36
Цитата Сообщение от Амир777 Посмотреть сообщение
android.support.constraint.RelativeLayou t
Замени на просто RelativeLayout.
Этот constraint никогда не работал.
0
 Аватар для petruchodd
129 / 126 / 22
Регистрация: 23.06.2009
Сообщений: 700
03.09.2018, 14:51
Цитата Сообщение от Амир777 Посмотреть сообщение
Java
1
2
3
ReadNews readNews = new ReadNews(this, recyclerView);
 readNews.execute();
recyclerView =(RecyclerView)findViewById(R.id.recyclerview);
просто в догонку.. походу тут упадет жесткоооо
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
03.09.2018, 14:51
Помогаю со студенческими работами здесь

Fatal Exception: main
Здравствуйте, пишу свое первое приложение, помогите пожалуйста. Проблема в том, что в коде никаких ошибок не отображается, а когда проверяю...

FATAL EXCEPTION: main
Всем привет. Не получается программка из урока с передачей данных из одного активити в другое. Уже третий день туплю, но не могу исправить...

FATAL EXCEPTION: main
Вот код: import com.independentsoft.exchange.Service; import android.app.Activity; import android.os.Bundle; public class...

FATAL EXCEPTION: main
Пишу свое 1 приложение, столкнулся с проблемой. при загрузке FATAL ERROR и все тут. Помогите что делать ? Вот код *.java package...

E/AndroidRuntime: FATAL EXCEPTION: main
я не могу понять в чем дело .... если можно объясните... сразу признаюсь я начинающий программист ...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
Новые блоги и статьи
Thinkpad X220 Tablet — это лучший бюджетный ноутбук для учёбы, точка.
Programma_Boinc 23.12.2025
Thinkpad X220 Tablet — это лучший бюджетный ноутбук для учёбы, точка. Рецензия / Мнение/ Перевод https:/ / **********/ gallery/ thinkpad-x220-tablet-porn-gzoEAjs . . .
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Как объединить две одинаковые БД Access с разными данными
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
Ломающие изменения в C#.NStar Alpha
Etyuhibosecyu 20.11.2025
Уже можно не только тестировать, но и пользоваться C#. NStar - писать оконные приложения, содержащие надписи, кнопки, текстовые поля и даже изображения, например, моя игра "Три в ряд" написана на этом. . .
Мысли в слух
kumehtar 18.11.2025
Кстати, совсем недавно имел разговор на тему медитаций с людьми. И обнаружил, что они вообще не понимают что такое медитация и зачем она нужна. Самые базовые вещи. Для них это - когда просто люди. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru