Home > Mobile >  The Error inflating class android. Support. V7. Widget. The Toolbar
The Error inflating class android. Support. V7. Widget. The Toolbar

Time:09-29

My program compile, run will collapse, said an error loading the v7 failure, but in the build. Is loaded in the gandle succeeded, see a lot of posts are not solved, really don't know what to do, please help , thank you very much
Style. The XML file:


<style name="AppTheme" parent "=" Theme. AppCompat. Light. NoActionBar "& gt;





</style>


MainActivity. Java file:
Package com. Example. Materialtest;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
The import androidx. Appcompat. Widget. The Toolbar;

Public class MainActivity extends AppCompatActivity {

@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
The Toolbar Toolbar=(Toolbar) the findViewById (R.i which oolbar);
SetSupportActionBar (toolbar);
}
}

Build. Gradle dependencies in the file:
Dependencies {
Implementation fileTree (dir: 'libs', include: [' *. Jar'])
Implementation 'androidx. Appcompat: appcompat: 1.0.2'
Implementation 'androidx. Constraintlayout: constraintlayout: 1.1.3'
TestImplementation 'junit: junit: 4.12'
AndroidTestImplementation 'androidx. Test: runner: 1.2.0'
AndroidTestImplementation 'androidx. Test. Espresso: espresso - core: 3.2.0'
Implementation 'com. Android. Support: appcompat - v7:29.0.0'
}

CodePudding user response:

Layout is given and see it

CodePudding user response:

The implementation of 'com. Android. Support: appcompat - v7:29.0.0' to keep implementation 'androidx. Appcompat: appcompat: 1.0.2' is ok

CodePudding user response:

Excuse me, have you solved this problem, I also met this kind of situation,

CodePudding user response:


reference 3 floor close meow meow response:
excuse me, have you solved the problem, I also met this kind of situation,

Reference the Toobar v7 package, delete v7, to androidx
  • Related