title: ClassNotFoundException DynamiteModuleInitializer Android
body: <p>Since i updated my android studio and sdk. these errors started occurring at once and preventing me from writing to the a child in the database, i have no idea what the problem is. but it seems that when i'm trying to write to the database from the "EditCarPostActivity" activity it is occurring, From other activities i can write and update and retrieve information perfectly. Please help with this problem. I will post some activities below</p>
  
  <p>Error 1 </p>
  
  <blockquote>
    <p>04-29 18:38:54.685 11007-11034/com.example.ahmad.carrental E/ChimeraFileApk: Failed to validate DexClassLoader.
        java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.DynamiteModuleInitializer" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)</p>
  </blockquote>
  
  <p>Error 2</p>
  
  <blockquote>
    <p>04-29 18:38:54.686 11007-11034/com.example.ahmad.carrental E/ChimeraModuleLdr: Failed to load code for module FileApk(/data/user_de/0/com.google.android.gms/app_chimera/m/0000002d/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk)
        ddp: Failed to load code for /data/user_de/0/com.google.android.gms/app_chimera/m/0000002d/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk</p>
  </blockquote>
  
  <p>Error 3</p>
  
  <blockquote>
    <p>04-29 18:38:54.686 11007-11034/com.example.ahmad.carrental W/ChimeraDebugLogger: Singleton logger instance not set.
    04-29 18:38:54.686 11007-11034/com.example.ahmad.carrental E/DynamiteLoaderV2: Failed to create module context.
        ddp: Failed to load code for /data/user_de/0/com.google.android.gms/app_chimera/m/0000002d/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk</p>
  </blockquote>
  
  <p><strong>EditCarPostActivity</strong></p>
  
  <pre><code> @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_edit_car_post);
  
      initialization();
      setupFirebaseAuth();
      setUpLocationSpinner();
      userID = mAuth.getCurrentUser().getUid();
  
  
      //Assigning Car object with its data from database.
      Observable.create(new ObservableOnSubscribe() {
          @Override
          public void subscribe(ObservableEmitter emitter) throws Exception {
              singleValueEventListener = new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      car = mFirebaseUtilities.getCarByUserID(userID,dataSnapshot);
                      editCarPostPresenter.populateViews(car);
                  }
  
                  @Override
                  public void onCancelled(DatabaseError databaseError) {
                      Log.e(TAG, "CANCELLED.");
                  }
              };
              mDatabaseReference.addValueEventListener(singleValueEventListener);
          }
      }).unsubscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
  
      //Save all the changes when done editing to database.
      checkButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              editCarPostPresenter.onSaveChanges(car);
          }
      });
  
      //When user click image button, start image selection from gallery
      tvImageButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(Intent.ACTION_PICK);
              intent.setType("image/*");
              startActivityForResult(intent,GALLERY_INT);
          }
      });
  
  }
  
  /**
   * Will listen for user image selection and will store the selected image in a uri object, then call getUriImage to update it
   * When the user finishes editing and clicks the check button along with any change in car information to the database.
   * @param requestCode
   * @param resultCode
   * @param data
   */
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      if(requestCode == GALLERY_INT &amp;&amp; resultCode == RESULT_OK){
  
          mProgressDialog.setMessage("Uploading .....");
          mProgressDialog.show();
          Uri uri  = data.getData();
  
          storagePathReference = mStorageReference.child("Photos").child(userID).child(uri.getLastPathSegment());
  
          //Update all the information with the image given as Uri
          storagePathReference.putFile(uri).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
  
                      Toast.makeText(mContext,"Image Upload success!",Toast.LENGTH_SHORT).show();
                      mProgressDialog.dismiss();
  
                      downloadImageUri = taskSnapshot.getDownloadUrl();
                      Picasso.get().load(downloadImageUri).fit().centerCrop().into(ivCarPicture);
                  }
              });
      }
  }
  
  public void deleteUnusedImages(Car car){
      car = this.car;
      String imageID = car.getPicture();
      for(int i = 0;i&lt;6;i++){
  
      }
  
  }
  
  
  //initalizing everything necessary here
  public void initialization(){
      mContext = getApplicationContext();
      editCarPostPresenter = new EditCarPostPresenter(this,this);
  
      //Adapter set up for spinners
      mArrayAdapter2 = ArrayAdapter.createFromResource(this,R.array.car_brands,android.R.layout.simple_spinner_item);
      mArrayAdapter = ArrayAdapter.createFromResource(this,R.array.car_status_array,android.R.layout.simple_spinner_item);
  
      //Status spinner set up
      statusSpinner = findViewById(R.id.createPostCarStatusSpinner_ID);
      statusSpinner.setAdapter(mArrayAdapter);
      statusSpinner.setOnItemSelectedListener(this);
      //Brand spinner set up
      brandSpinner = findViewById(R.id.createPostCarBrandSpinner_ID);
      brandSpinner.setAdapter(mArrayAdapter2);
      brandSpinner.setOnItemSelectedListener(this);
  
      layoutContainer = findViewById(R.id.createPostLinearLayout_ID);
      tvDistance = new TextView(this);
      tvDistance.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      tvDistance.setText("Distance Travelled");
      etDistance = new EditText(this);
      etDistance.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  
      //margin settings editText
      layoutParamsEt = (LinearLayout.LayoutParams)etDistance.getLayoutParams();
      layoutParamsEt.setMargins(0,10,0,0);
      etDistance.setLayoutParams(layoutParamsEt);
  
      //margin settings textView
      layoutParamsTv = (LinearLayout.LayoutParams)tvDistance.getLayoutParams();
      layoutParamsTv.setMargins(0,10,0,0);
      tvDistance.setLayoutParams(layoutParamsTv);
  
      ivCarPicture = findViewById(R.id.createPostCarPic_ID);
      tvImageButton = findViewById(R.id.createPostCarLinkPic_ID);
      etCarLocation = findViewById(R.id.createPostCarLocation_ID);
      etDescription = findViewById(R.id.createPostCarDes_ID);
      etPrice = findViewById(R.id.createPostCarPrice_ID);
      etModel = findViewById(R.id.createPostCarModel_ID);
      checkButton = findViewById(R.id.check_ID);
      mFirebaseUtilities = new FirebaseUtilities(this);
      mStorageReference = FirebaseStorage.getInstance().getReference();
      mProgressDialog = new ProgressDialog(this);
  }
  
  private void setUpLocationSpinner() {
  
      ArrayAdapter&lt;String&gt; listOfCities = new ArrayAdapter&lt;&gt;(getBaseContext(),
              android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.TR_cities));
  
      //--- to ensure user is restricted to selections from drop-down menu
      etCarLocation.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              carLoactionStr = etCarLocation.getAdapter().getItem(position).toString();
          }
      });
  
      etCarLocation.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
              for (int i = 0; i &lt; etCarLocation.getAdapter().getCount(); i++) {
                  if (etCarLocation.getText().toString().equals(etCarLocation.getAdapter().getItem(i))) {
                      carLoactionStr = etCarLocation.getAdapter().getItem(i).toString();
                  } else
                      carLoactionStr = null;
              }
          }
  
          @Override
          public void afterTextChanged(Editable s) {
          }
      });
  
  
      //start autocomplete after 1 letter
      etCarLocation.setThreshold(1);
      etCarLocation.performCompletion();
      etCarLocation.setAdapter(listOfCities);
  }
  
  /**
   * Listener for car status spinner and brand spinner
   * @param parent
   * @param view
   * @param position
   * @param id
   */
  @Override
  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
      Spinner spinner = (Spinner)parent;
  
      if(spinner.getId() == R.id.createPostCarStatusSpinner_ID){
          TextView textView = (TextView) view;
          carStatusStr = textView.getText().toString();
          addDynamicViews(position);
      }
      else if(spinner.getId() == R.id.createPostCarBrandSpinner_ID){
          TextView textView = (TextView) view;
          carBrandStr = textView.getText().toString();
      }
  
  }
  
  @Override
  public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
  }
  
  /**
   * Dynamic views creation done by handling user spinner selection for first hand or second hand car status.
   *@param position: position of selected value from spinner
   */
  public void addDynamicViews(int position){
     /*
     * it crashes if you change from first hand to second hand twice at the same time. so dont do it*/
      if(position == 1){
          layoutContainer.addView(tvDistance);
          layoutContainer.addView(etDistance);
      }
      else if(position == 0){
          Log.i(TAG,"entering");
         //mFirebaseUtilities.removeNodeDynamically();
          layoutContainer.removeView(tvDistance);
          layoutContainer.removeView(etDistance);
      }
  }
  
  @Override
  public void setBrand(String brand) {
      int spinnerPos = mArrayAdapter.getPosition(brand);
      brandSpinner.setSelection(spinnerPos);
  }
  
  @Override
  public void setPrice(int price) {
      etPrice.setText(String.valueOf(price));
  }
  
  @Override
  public void setLocation(String location) {
      etCarLocation.setText(location);
  }
  
  @Override
  public void setDescription(String description) {
      etDescription.setText(description);
  }
  
  @Override
  public void setModel(String model) {
      etModel.setText(model);
  }
  
  @Override
  public void setDistance(String distance) {
      etDistance.setText(distance);
  }
  
  @Override
  public void setStatus(String status) {
      int spinnerPos = mArrayAdapter.getPosition(status);
      statusSpinner.setSelection(spinnerPos);
  }
  
  @Override
  public void setPicture(String picture) {
     Picasso.get().load(picture).fit().centerCrop().into(ivCarPicture);
  }
  
  @Override
  public String getBrand() {
      return carBrandStr;
  }
  
  @Override
  public String getDescription() {
      return etDescription.getText().toString();
  }
  
  @Override
  public String getLocation() {
      return carLoactionStr;
  }
  
  @Override
  public String getModel() {
      return etModel.getText().toString();
  }
  
  @Override
  public String getStatus() {
      return carStatusStr;
  }
  
  @Override
  public String getPicture() {
      return downloadImageUri.toString();
  }
  
  @Override
  public int getPrice() {
      String priceViewTemp = etPrice.getText().toString();
      if (priceViewTemp.equals("")) {
          return 0;
      } else {
          return Integer.valueOf(etPrice.getText().toString());
      }
  }
  
  @Override
  public String getDistance() {
      String distanceViewTemp = etDistance.getText().toString();
      if (distanceViewTemp.equals("")) {
          return "0";
      } else {
          return etDistance.getText().toString();
      }
  }
  
  /*************************************** Firebase *******************************************/
  private void setupFirebaseAuth() {
      mAuth = FirebaseAuth.getInstance();
  
      mFirebaseDatabase = FirebaseDatabase.getInstance();
      mDatabaseReference = mFirebaseDatabase.getReference();
  
      mAuthStateListener = new FirebaseAuth.AuthStateListener() {
          @Override
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
              FirebaseUser user = firebaseAuth.getCurrentUser();
  
              if (user != null) {
                  //User is signed in
                  Log.d(TAG, "onAuthStateChanged: user signed in : " + user.getUid());
              } else {
                  //User is signed out
                  Log.d(TAG, "onAuthStateChanged: user signed out");
              }
          }
      };
  
      mDatabaseReference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
  
  
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  }
  @Override
  public void onPause() {
      super.onPause();
      if (singleValueEventListener != null) {
          mDatabaseReference.removeEventListener(singleValueEventListener);
      }
  }
  @Override
  public void onResume(){
      super.onResume();
      mDatabaseReference.addListenerForSingleValueEvent(singleValueEventListener);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>If you need more information you can ask. And yes my firebase auth is enabled as well as storage and realtime database</p>