Browse Source

Better Android deployment error messages, ensure res/values folder exists

Josh Engebretson 9 years ago
parent
commit
3e16c16822
1 changed files with 18 additions and 1 deletions
  1. 18 1
      Source/ToolCore/Build/AndroidProjectGenerator.cpp

+ 18 - 1
Source/ToolCore/Build/AndroidProjectGenerator.cpp

@@ -174,6 +174,7 @@ bool AndroidProjectGenerator::GenerateProjectProperties()
 
 bool AndroidProjectGenerator::GenerateStringXML()
 {
+    FileSystem* fs = GetSubsystem<FileSystem>();
     ToolSystem* toolSystem = GetSubsystem<ToolSystem>();
     Project* project = toolSystem->GetProject();
     AndroidBuildSettings* settings = project->GetBuildSettings()->GetAndroidBuildSettings();
@@ -193,11 +194,27 @@ bool AndroidProjectGenerator::GenerateStringXML()
     strings.AppendWithFormat("<string name=\"app_name\">%s</string>\n", appName.CString());
 
     strings += "</resources>\n";
-
+    
+    // Create res/values if it doesn't exist
+    if (!fs->DirExists(buildPath_ + "/res/values"))
+    {
+        fs->CreateDirsRecursive(buildPath_ + "/res/values");
+    }
+    
+    // Check that we successfully created it
+    if (!fs->DirExists(buildPath_ + "/res/values"))
+    {
+        errorText_ = "Unable to create directory: " + buildPath_ + "/res/values";
+        return false;
+    }
+    
     File file(context_, buildPath_ + "/res/values/strings.xml", FILE_WRITE);
 
     if (!file.IsOpen())
+    {
+        errorText_ = "Unable to write: " + buildPath_ + "/res/values/strings.xml";
         return false;
+    }
 
     file.Write(strings.CString(), strings.Length());