Androidstudio giving unusual error while opening project fonts

Asked

Viewed 59 times

0

Androidstudio is misopening the project files, see one of the cases the source Cmapbuffer.java. Just to reinforce, it’s the same file being opened by the OS text editor and the IDE, at first it opens the file. java correctly and in the second opens an XML that does not correspond to the Cmapbuffer.java file..

when I open Cmapbuffer.java in the OS text editor:

    package lib.map.buffer;

    import android.widget.FrameLayout;

    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.MapView;
    import com.google.android.gms.maps.UiSettings;
    import com.google.android.gms.maps.model.LatLng;

    import lib.map.CMapListenerList;
    import lib.map.def.MAP;

    //-------------------------------------

    public class CMapBuffer
    {
      private static final CMapData m_mbu[] = new CMapData[MAP.count];

      //-----------------------------------

      public static void put(int key, FrameLayout root, MapView view)
      {
        m_mbu[key] = new CMapData(root,view);
      }

      //-----------------------------------

      public static void put(int key, GoogleMap map)
      {
        m_mbu[key].m_map = map;
        m_mbu[key].m_mli = new CMapListenerList(map);
        m_mbu[key].m_view.onResume();
      }

*** E assim vai, corretamente.

When I open Cmapbuffer.java on Androidstudio

<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/topPanel"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
     android:gravity="top|center_horizontal">

    <!-- If the client uses a customTitle, it will be added here. -->

    <LinearLayout
        android:id="@+id/title_template"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_marginTop="24dp"
        android:orientation="vertical">

        <ImageView
            android:id="@android:id/icon"
            android:adjustViewBounds="true"
            android:maxHeight="24dp"
            android:maxWidth="24dp"
            android:layout_gravity="center_horizontal"
            android:layout_width="wrap_content"

It took me a while to figure out that the source file was right on the hard drive. I have a recent backup of the project, but copying the file doesn’t resolve. Attempts that without success:

  • Exclusion of . Gradle
  • Exclusion of . idea
  • Deletion of IML files
  • Copy source file from OS
  • Copy the OS source file to Androidstudio
  • Clear cache Restart

Follow a screenshot of Androidstudio to reinforce the weirdness.

inserir a descrição da imagem aqui


Content of proguard-Rules.pro displayed on Androidstudio

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2">
    <string msgid="4600421777120114993" name="abc_action_bar_home_description">"Krmarjenje domov"</string>
    <string msgid="1594238315039666878" name="abc_action_bar_up_description">"Krmarjenje navzgor"</string>
    <string msgid="3588849162933574182" name="abc_action_menu_overflow_description">"Več možnosti"</string>
    <string msgid="4076576682505996667" name="abc_action_mode_done">"Končano"</string>
    <string msgid="7468859129482906941" name="abc_activity_chooser_view_see_all">"Pokaži vse"</string>
    <string msgid="2031811694353399454" name=

Contents of proguard-Rules.pro - correct - displayed in the notepad

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
  • The error is happening because a file that should have the xml extension is saved as java. Checks that it’s right in the way the androidStudio is looking for

  • It’s the same source file - Cmapbuffer.java - the first opened by the OS text editor and the second opened by the IDE

1 answer

0

It seems to me that this is a layout file. You need to change its extension from .java for .xml and change the location of the file. You have to take it out of the package that is, and put it in the folder res/layout.

  • It’s the same source - Cmapbuffer.java - the first one opened by the OS text editor and the second one opened by the IDE

  • 1

    There is no way to be the same. Right click on the file that is error in Android Studio and goes in "Show in Explorer". You will see that they are different files.

  • I did this: "Show in Explorer", opened the file location, opened with the note pad displays the Cmapbuffer.java file correctly. Double click on the file in Androidstudio displays the XML. That’s why I said "unusual", can not enterder :(

  • looks like I’ll be able to solve - more than a day trying - I copied the project files to an auxiliary folder and copied this folder back to Androidstudio. Strange problem, strange solution.

  • But it worked??

  • I’m doing it and it’s solving it. It’s like Androidstudio has a FAT and by "recopying" the file it’s set.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.